refresh
refresh

Reputation: 1329

Using 'DropCreateDatabaseWhenModelChanges' error

When I add this code Database.SetInitializer(new DropCreateDatabaseWhenModelChanges()); in DbContext file, I get the following error:

The type or namespace name 'DropCreateDatabaseWhenModelChanges' could not be found (are you missing a using directive or an assembly reference?)

I have included the System.Data.Entity namespace. What could I be missing? EDIT I tried with DropCreateDatabaseIfModelChanges, in vain.

Upvotes: 0

Views: 247

Answers (2)

user3762810
user3762810

Reputation: 143

Use Database.SetInitializer(new DropCreateDatabaseIfModelChanges<StudentDbContext>());

Upvotes: 1

LiranBo
LiranBo

Reputation: 2126

you mean DropCreateDatabaseIfModelChanges not DropCreateDatabaseWhenModelChanges

Upvotes: 0

Related Questions