Asp.net Identity Validation Error

后端 未结 3 1129
闹比i
闹比i 2020-12-02 13:04

I want integrate IdentityContext with mydbcontext but i am taking this error

One or more validation errors were detected during model generation:

Ivdb.Dal.Co

3条回答
  •  孤城傲影
    2020-12-02 13:30

    If you don't want to call base.OnModelCreating and want to do your own mapping, your mapping should look like this:

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        modelBuilder.Entity().HasKey(r => r.Id).Property(p => p.Name).IsRequired();
        modelBuilder.Entity().HasKey(r => new { r.RoleId, r.UserId });
        modelBuilder.Entity().HasKey(u => new {u.UserId, u.LoginProvider, u.ProviderKey});
    }
    

    If you put the key for IdentityUserLogin only on UserId, you get DbEntityValidationExceptions when using the default google login.

提交回复
热议问题