0

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.

refresh
  • 1,319
  • 2
  • 20
  • 71

2 Answers2

1

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

user3762810
  • 143
  • 1
  • 3
  • 13
0

you mean DropCreateDatabaseIfModelChanges not DropCreateDatabaseWhenModelChanges

LiranBo
  • 2,054
  • 2
  • 23
  • 39