this is class diagram of my application:
when i want to run this simple code:
using (var db = new AppContext())
{
var u1 = new User { firstName = "A", lastName = "B" };
db.users.Add(u1);
db.SaveChanges();
Console.ReadLine();
}
this exception thrown:
Additional information: Unable to determine the principal end of an association between the types 'CodeFirstNewDataBase.Model.User' and 'CodeFirstNewDataBase.Model.User'. The principal end of this association must be explicitly configured using either the relationship fluent API or data annotations.
and i'm using Table per Hierarchy mapping in my project as you seen below:"
public class BaseEntityConfig : EntityTypeConfiguration<BaseEntity>
{
public BaseEntityConfig()
{
this.Property(x => x.id).HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
}
}
public class UserConfig : EntityTypeConfiguration<User>
{
public UserConfig()
{
this.Map(m =>
{
m.MapInheritedProperties();
m.ToTable("User");
});
}
}
how can i solve this problem?
i'm new to EF code first