2017-07-19 55 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

相关问题