This is probably just because my knowledge with the EF Code First fluent API is lacking, but I'm stumped.
I want to model the following:
- A Groups collection with Id and Name
- A Users collection with Id and Name
- Each user is assigned to exactly one primary group
- Each user may have zero or many secondary groups
The table structure I'm going for would look like:
Groups
- Id
- Name
Users
- Id
- Name
- PrimaryGroupId
SecondaryGroupAssignments
- UserId
- GroupId
I've been beating my head against a wall trying to model this with EF Code First, but I can't get it to accept both relationships between User and Group. Sorry for not posting any .NET code (I'm happy to), but it's probably all wrong anyway.
Is there a way to make EF model this? I'm assuming I have to do some sort of configuration with the Fluent API. Maybe a better question is: is there any good, definitive reference for the Fluent API?
Thanks!