2017-07-19 77 views
0

我試圖使用代碼第一次遷移的方法(從代碼genrate數據庫)。但面臨錯誤。這裏是我的代碼ApplicationDbContext.OnModelCreating(ModelBuilder):找不到合適的方法覆蓋

using Microsoft.AspNet.Identity.EntityFramework; 

namespace IMChatApp.Models 
{ 
    // You can add profile data for the user by adding more properties to your ApplicationUser class, please visit http://go.microsoft.com/fwlink/?LinkID=317594 to learn more. 
    public class ApplicationUser : IdentityUser 
    { 
    } 

    public class ApplicationDbContext : IdentityDbContext<ApplicationUser> 
    { 
     public ApplicationDbContext() 
      : base("DefaultConnection") 
     { 
     } 
     protected override void OnModelCreating(ModelBuilder modelBuilder) 
     { 
      modelBuilder.IncludeMetadataInDatabase = false; 
     } 
     public System.Data.Entity.DbSet<JustDoIt.Models.user> users { get; set; } 
    } 
} 
+0

當您將該方法設爲公開而不是受保護時它工作嗎? –

+2

只需鍵入'override'>命中空間>從intellisense中選擇方法,就不會留下這樣的錯誤空間。 – niksofteng

回答

0

按照documentation,該OnModelCreating方法需要一個DbModelBuilder,而不是一個ModelBuilder

相關問題