KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a model like public class User { [Key] public long UserId { get; set; } [Required] public String Nickname { get; set; } public virtual ICollection<Town> Residencies { get; set; } public virtual ICollection<Town> Mayorships { get; set; } } and public class Town { [Key] public long TownId { get; set; } [Required] public String Name { get; set; } public virtual ICollection<User> Residents { get; set; } public virtual ICollection<User> Mayors { get; set; } } I was hoping EF would create two many to many relationships using automatically created TownResidents and TownMayors table. I can't seem to find the necessary convention or explicit annotation to get this result. Instead I am getting two FK UserIds in the Town table and two FK TownIds in the User table. Any ideas how to get EF to see these at two many to many relationships? Thanks
Tags (comma-separated)
Save Edits
Cancel