Po updacie bazy nie porafie zmapować tabeli "Customers" do ApplicationUsers w relacji one to one. Nie rozumiem, jak może nie pokrywać się klucz. Gdzie popełniam bląd?
Source.Database.IdentityUserLogin: : EntityType 'IdentityUserLogin' has no key defined. Define the key for this EntityType.
Source.Database.IdentityUserRole: : EntityType 'IdentityUserRole' has no key defined. Define the key for this EntityType.
ApplicationUser_Customers_Target: : Multiplicity is not valid in Role 'ApplicationUser_Customers_Target' in relationship 'ApplicationUser_Customers'. Because the Dependent Role properties are not the key properties, the upper bound of the multiplicity of the Dependent Role must be ''.
ApplicationUser_Customers_Source_ApplicationUser_Customers_Target: : The types of all properties in the Dependent Role of a referential constraint must be the same as the corresponding property types in the Principal Role. The type of property 'ApplicationUserId' on entity 'Customers' does not match the type of property 'Id' on entity 'ApplicationUser' in the referential constraint 'ApplicationUser_Customers'.
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
public class ApplicationUser : IdentityUser
{
public virtual Customers Customers { get; set; }
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
{
// Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
// Add custom user claims here
return userIdentity;
}
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<ApplicationUser>()
.HasOptional(a => a.Customers)
.WithRequired(ab => ab.ApplicationUser);
}
public class Customers
{
[ForeignKey("ApplicationUser")]
public int ApplicationUserId { get; set; }
public virtual ApplicationUser ApplicationUser { get; set; }
}