Reputation: 611
My question is a follow-on to EF6 Does not generate foreign key association from database but that answer was not sufficient to resolve my issue. I am using VS 2013 update 4/EF 6/SQL Server 2014.
In my case users represent linux accounts and have the following structure:
Where Accounts.Username and Groups.Name are primary keys and there are unique indexes on Accounts.UID and Groups.GID. These are related through the GroupMembership table. EF creates:
No associations. Interestingly, when I change the Primary Keys:
So that Accounts.UID and Groups.GID become the primary keys and Accounts.Username and Groups.Name have the unique indexes then I get:
It appears as though a many-many association will only be created for primary keys. If I try to create one manually in the designer, it won't use my GroupMembership table and I don't know enough to dig in past that.
Of course, I can work around my issue simply enough by using the updated schema but I am trying to improve my EF skills.
Upvotes: 0
Views: 342
Reputation:
It wouldn't surprise me at all if EF won't use varchar columns for keys...
Upvotes: 0