I've searched to a help for connection between own models and the existing authorization models in Code First
. But have nothing found what helped to me. (For example, trying this).
My exact problem:
I have a model with the entity added_from
or last_edited_from
and want to set a reference to the user-id. I tried it in some different ways.
The most logical way for me was:
public class aTable
{
[...]
[ForeignKey("last_edited_from")]
public ApplicationUser userFK { get; set; }
public string last_edited_from { get; set; }
}
But when I tried this I got the following error in the Package Manager console (after "add-migration")
MyProj.DAL.IdentityUserLogin: : EntityType 'IdentityUserLogin' has no key defined. Define the key for this EntityType.
MyProj.DAL.IdentityUserRole: : EntityType 'IdentityUserRole' has no key defined. Define the key for this EntityType.
IdentityUserLogins: EntityType: EntitySet 'IdentityUserLogins' is based on type 'IdentityUserLogin' that has no keys defined.
IdentityUserRoles: EntityType: EntitySet 'IdentityUserRoles' is based on type 'IdentityUserRole' that has no keys defined.