I have a database that contains a couple of composite foreign keys. For example, here is the generation script for the foreign key:
ALTER TABLE [dbo].[WorkingRosters] WITH NOCHECK ADD CONSTRAINT
[FK_WorkingRoster_ShiftLeaveCode] FOREIGN KEY([OrganizationID], [ShiftLeaveCode])
REFERENCES [dbo].[ShiftLeaveCodes] ([OrganizationID], [Code])
GO
I am attempting to use Entity Framework 5 Database-First to generate a model from this database. However, the associations for the composite foreign keys are not being generated with all the tables and other simple foreign keys.
How can I either:
- manually create these composite foreign keys in the xml behind the edmx (painful)
- have entity framework properly generate these foreign keys so that I have have the mappings
Thanks!
OrganizationID
andCode
composite primary key of youShiftLeaveCodes
table? If not (for example if it is just unique index) it will not work. – Misspell