ASP.NET身份 - 每种类型的多个对象集,不支持 [英] ASP.NET Identity - Multiple object sets per type are not supported

查看:140
本文介绍了ASP.NET身份 - 每种类型的多个对象集,不支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序中使用ASP.NET识别错误。

I got an error using ASP.NET Identity in my app.

每种类型的多个对象集,不支持。的对象集
  用户身份和用户可以同时包含类型的实例
  建议Platform.Models.ApplicationUser。

Multiple object sets per type are not supported. The object sets 'Identity Users' and 'Users' can both contain instances of type 'Recommendation Platform.Models.ApplicationUser'.

我看到有关此错误计算器中的几个问题。都表明在相同类型的两个DbSet对象。但在我的DbContext有没有同类型DbSets的。除了在洛期间,扔在FindAsync()方法。

I saw a few questions about this error in stackoverflow. All indicate on two DbSet object of the same type. But in my DbContext there aren't the same types of DbSets. Exception in thrown on FindAsync() method, during loggin in.

if (ModelState.IsValid)
    var user = await UserManager.FindAsync(model.UserName, model.Password);
    if (user != null && user.IsConfirmed)
    {

问题是我不具有相同类型的两个DbSets。我的上下文看起来像:

The problem is I don't have two DbSets of the same type. My Contexts look like that:

public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
    public ApplicationDbContext()
        : base("DefaultConnection")
    {
    }

    public System.Data.Entity.DbSet<RecommendationPlatform.Models.ApplicationUser> IdentityUsers { get; set; }

}

public class RecContext : DbContext
{
    public RecContext()
        : base("RecConnection")
    {
        Database.SetInitializer<RecContext>(new DropCreateDatabaseIfModelChanges<RecContext>());
    }

    public DbSet<Recommendation> Recommendations { get; set; }
    public DbSet<Geolocation> Geolocations { get; set; }
    public DbSet<Faq> Faqs { get; set; }
    public DbSet<IndexText> IndexTexts { get; set; }
}

这是什么原因这个问题?也许有内置的ASP.NET身份功能的东西连接?总之,什么是用户类型?我没有在我的应用程序...

What could cause this problem? Maybe something connected with in-built ASP.NET Identity functionalities? Anyway, what is Users type? I don't have it in my app...

推荐答案

您这样做有两个 DbSet s`相同类型的。

You do have two DbSets` of the same type.

IdentityDbContext&LT; T&GT; 本身包含用户属性声明:

public DbSet<T> Users { get; set; }

您正在声明在你的类第二。

You're declaring second one in your class.

这篇关于ASP.NET身份 - 每种类型的多个对象集,不支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆