ApplicationDbContext.OnModelCreating(ModelBuilder):找不到合适的方法来覆盖

时间:2017-07-19 04:57:39

标签: c# asp.net entity-framework

我正在尝试使用代码优先迁移方法(代码中的genrate数据库)。但面临错误。这是我的代码

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

1 个答案:

答案 0 :(得分:1)

根据documentationOnModelCreating方法需要DbModelBuilder,而不是ModelBuilder