2011-03-24 6 views
7

D'accord, donc je viens de mettre à travers NuGet au code EF First 4.1 et maintenant je reçois l'erreur de génération suivante dans mon JobSiteContext.cs classe:EF 4.1 Code du premier numéro après une mise

« Le nom « DbDatabase » does ne pas exister dans le contexte actuel »

Voici mon 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>()); 
    } 
} 

me pointer quelqu'un peut-il dans la bonne direction?

Merci Paul

Répondre

0
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(); 

       } 
      } 
     } 
Questions connexes