Entity Framework - DB-First - Composite Foreign Keys
Asked Answered
M

1

10

I have a database that has a table with a 2-column primary composite key (one int, one bigint.) I have two tables that have a composite foreign key, referencing the first table's composite primary key. The relationships are (as far as I know,) fine and dandy on the database itself.

When generating a DB context via DB-first EF6, these relationships/navigation properties are not represented in the generated models (No virtual members in the two child tables referencing the parent table.)

Since it's db-first, I can't modify the models.

Mandiemandingo answered 21/5, 2015 at 16:38 Comment(1)
Which database provider do you use? I'm using SQL Anywhere 16 and I am having the same issue.Hiatus
V
1

In this case you can put those relationships into the onmodelcreating function in db context. We can put constraint there.

Vickievicksburg answered 31/3, 2017 at 6:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.