Entity Framework 6 Database First Doesn't Generate Entity on Table With Composite Key

composite-primary-key ef-database-first entity-framework entity-framework-6 sql-server

Accepted Answer

Zzz-5-zzz and Gert Arnold's remark helped me choose the appropriate path.

Object Framework built the entity after I added a column in addition to the two main keys. For which EF Database First will construct an object, consider the following example table definition:

create table [dbo].[CustomerRequests] (
    [CustomerId] int not null,
    [RequestId] int not null,
    [TimestampUtc] datetime not null,
    constraint [PK_CustomerRequests] primary key clustered ([CustomerId] asc, [RequestId] asc),
    constraint [FK_CustomerRequests_Customers] foreign key ([CustomerId]) references [dbo].[Customers] ([CustomerId]),
    constraint [FK_CustomerRequests_Requests] foreign key ([RequestId]) references [dbo].[Requests] ([RequestId])
);
3
10/13/2017 8:06:11 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow