public static void CreateBD(DbContext context) { try { context.Database.CreateIfNotExists(); if (!context.Database.CompatibleWithModel(throwIfNoMetadata: true)) { throw new Exception("Delete and Create DataBase"); } } catch { My.DeleteBD(context); context.Database.CreateIfNotExists(); } }