I've followed tutorials but can't seem to get this to work. What I'm trying to achieve is that I have a Client model which has an owner handling the client. That owner is any of the ApplicationUsers. Right now this is the problem that I have:
Multiple object sets per type are not supported. The object sets 'ApplicationUsers' and 'Users' can both contain instances of type 'MyApp.Models.ApplicationUser'.
Here's the Client model. I added the ApplicationUserId there to make it easier to use it directly sometimes.
public class Client
{
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Phone { get; set; }
public string Email { get; set; }
// Who does this client belong to
public virtual ApplicationUser User { get; set; }
public string ApplicationUserId { get; set; }
}
I can add a new controller and views using scaffolding for the Client. It even builds without any issues but when I run the site I get the Multiple object sets per type error.
Scaffolding also adds Clients to ApplicationDbContext (set in IdentityModels.cs). I haven't touched any of the Identity files after VS automatically generated them so I don't believe there's an issue with them.
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext()
: base("DefaultConnection", throwIfV1Schema: false)
{
}
public static ApplicationDbContext Create()
{
return new ApplicationDbContext();
}
public System.Data.Entity.DbSet<MyApp.Models.Client> Clients { get; set; }
}
What's causing the Multiple object sets per type are not supported error? I've spent hours trying to figure this out. Thanks.