ASP.NET Identity - Multiple Object Sets Per Type Are Not Supported

ASP.NET Identity - Multiple object sets per type are not supported

You do have two DbSets` of the same type.

IdentityDbContext<T> itself contains Users property declared as:

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

You're declaring second one in your class.

MVC 5 Multiple object sets per type are not supported

Your class representation of

public class ApplicationDbContext
: IdentityDbContext<ApplicationUser, ApplicationRole, int,
ApplicationUserLogin, ApplicationUserRole, ApplicationUserClaim>
{...}

already has a Users property

public virtual IDbSet<TUser> Users { get; set; }

where TUser for you will be ApplicationUser.

You need to replace all instance of where you have db.ApplicationsUsers to db.Users

example:

var applicationUsers = db.ApplicationUsers.Include(a => a.Department).Include(a => a.Depot);

changes to:

var applicationUsers = db.Users.Include(a => a.Department).Include(a => a.Depot);

ASP.NET Identity - Multiple object sets per type

Check in your IdentityDbContext, the ApplicationRoles already define there may be it looks like that:

public System.Data.Entity.DbSet<ApplicationRoles> Roles{ get; set; }

Remove that one, this error come while ApplicationRoles declares again in XXXcontext....

Multiple object sets per type are not supported Asp.net MVC

You cannot have two classes with the same name, even if the namespaces are different, in the same context. Keyword here is SAME context. If you had another context, then it will be fine. This is because even though you are using code first approach, EF creates an EDMX file behind the scenes. The rules of EDMX are that you cannot have two tables with the same name in the same EDMX.

Multiple object sets per type are not supported. The object sets 'ApplicationUsers' and 'Users' can both contain instances of type ApplicationUser

I ended up renaming ApplicationUser to User, rescaffolding and everything magically started working.

Looks like the templates are a bit out of wack.

Multiple object sets per type are not supported. The object sets IdentityUsers'and Users can both contain instances of type

Your problem is this line:

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

IdentityDbContext already contains a Users property with type IDbSet<ApplicationUser>. You don't need to add your own DbSet for ApplicationUser. Remove that line and you're good.

How to solve the Multiple object sets per type are not supported problem with Entity Framework

Would this help?

public class FhemContext : DbContext
{
public virtual DbSet<History> History { get; set; }
public virtual DbSet<Current> Current{ get; set; }
}

public class LogEntry
{
public DateTime Timestamp { get; set; }
public string DEVICE { get; set; }
public string TYPE { get; set; }
public string EVENT { get; set; }
public string READING { get; set; }
public string VALUE { get; set; }
public string UNIT { get; set; }
}

public class Current : LogEntry
{
}

public class History : LogEntry
{
}

And the map the type History to the table history and so forth.

Entity Framework Multiple object sets per type are not supported.

You're telling EF to create the model object L_Colaborador twice in your DBContext. I think what you mean to do is this:

public DbSet<L_Colaborador> L_Colaboradores { get; set; }
public DbSet<L_ColaboradorPais> L_ColaboradorPais { get; set; }


Related Topics



Leave a reply



Submit