EF 4.1 First code after upgrade

Ok, so I just upgraded NuGet to EF Code First 4.1, and now I got the following build error in the JobSiteContext.cs class:

"The name" DbDatabase "does not exist in the current context"

Here is my code:

public class JobSiteContext : DbContext { public DbSet<JobSite.Models.Job> Jobs { get; set; } public DbSet<JobSite.Models.Location> Locations { get; set; } public DbSet<JobSite.Models.Profile> Profiles { get; set; } public JobSiteContext() { // Instructions: // * You can add custom code to this file. Changes will *not* be lost when you re-run the scaffolder. // * If you want to regenerate the file totally, delete it and then re-run the scaffolder. // * You can delete these comments if you wish // * If you want Entity Framework to drop and regenerate your database automatically whenever you // change your model schema, uncomment the following line: DbDatabase.SetInitializer(new DropCreateDatabaseIfModelChanges<JobSiteContext>()); } } 

Can someone point me in the right direction?

Thanks Paul

+7
source share
2 answers
+12
source
 public class Initializer : IDatabaseInitializer<AuthenticationContext> { public void InitializeDatabase(AuthenticationContext context) { if (context.Database.Exists() && !context.Database.CompatibleWithModel(false)) context.Database.Delete(); if (!context.Database.Exists()) { context.Database.Create(); } } } 
0
source

All Articles