KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm trying to set up a many to many relationship in EF code first but the default conventions is getting it wrong. The following classes describes the relationship: class Product { public int Id { get; set; } public string Name { get; set; } } class Account { public int Id { get; set; } public string Name { get; set; } public virtual ICollection<Product> Products { get; set; } } One Account can have many Products. However the EF conventions will create the DB tables as: Products Table -------------- Id Name Account_Id <- What is this? Accounts Table -------------- Id Name This doesn't look like a many-to-many table structure? How can i get configure the fluent API to reflect the relationship and create an intermediary table: AccountProducts Table --------------------- Account_Id Product_Id
Tags (comma-separated)
Save Edits
Cancel