In a VS 2013 RTM, MVC 5 project with EF 6, I tried to scaffold a controller based on the ApplicationUser (default with individual accounts authentication). Both Applic
Wow. I'm really surprise that no one actually got to the root of this, and instead, are just recommending workarounds.
IdentityDbContext
already contains a property:
`public virtual IDbSet Users { get; set; }
When you subclass IdentityDbContext
to create your own application-specific context, you must specify what class satisfies the TUser
generic. The default is:
public ApplicationDbContext : IdentityDbContext
Which then means that you functionally have a property already via inheritance in the form of:
public IDbSet Users { get; set; }
If you then add another property to your application-specific context such as:
public DbSet ApplicationUsers { get; set; }
You now have the same entity tracked by two DbSet
s, and you get that error. The solution? Simply don't add your own DbSet
for ApplicationUser
. There's no need to rename or override anything.