2011-03-24 13 views
7

ठीक अपग्रेड, तो मैं बस एफई कोड पहले 4.1 करने के लिए NuGet के माध्यम से उन्नत किया और अब मैं अपने JobSiteContext.cs वर्ग के भीतर निम्नलिखित निर्माण त्रुटि मिलती है:एफई 4.1 कोड पहले जारी होने के बाद

"नाम 'DbDatabase' करता है

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

किसी को भी सही दिशा में मुझे बात कर सकते हैं: वर्तमान संदर्भ "

यहाँ मेरी कोड में मौजूद नहीं?

धन्यवाद पॉल

उत्तर

12

अब यह सिर्फ Database है।

यहाँ देखें: http://blogs.msdn.com/b/adonet/archive/2011/03/15/ef-4-1-release-candidate-available.aspx

+0

तो मैं देख रहा हूँ :) 'डाटाबेस' को 'DbDatabase' का नाम बदलें। यह कक्षा डेटाबेस प्रारंभकर्ता वर्गों के साथ 'System.Data.Entity' नामस्थान में भी स्थानांतरित हो गई है। धन्यवाद! –

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

       } 
      } 
     } 
संबंधित मुद्दे