In an attempt to separate my domain model and identity model, I have two User entities.
In the domain model
This is used to relate Profiles to Users
class User
{
public Guid Id { get; set; }
public string UserName { get; set; }
}
In the identity model (using AspNet.Identity.EntityFramework)
This is used to authenticate users
class ApplicationUser : IdentityUser<Guid, ApplicationUserLogin, ApplicationUserRole, ApplicationUserClaim>
{
// Has the same properties (and property types) as User
}
Upon creating the database, this results in two tables; AspNetUsers and Users
Users contains identical information to AspNetUsers (only Id and UserName)
What I actually want is for users to map to the AspNetUsers table, but only pull back the Id and UserName for each record in that table
Using fluent configuration
modelBuilder.Entity<User>().ToTable("AspNetUsers");
Resulting error:
The entity types 'User' and 'ApplicationUser' caot share table 'AspNetUsers' because they are not in the same type hierarchy or do not have a valid one to one foreign key relationship with matching primary keys between them.
How can I resolve this?
