Entity Framework - DB-First - Composite Foreign Keys

composite-key database-first ef-database-first entity-framework entity-framework-6

Question

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.

1
10
5/21/2015 4:45:50 PM

Popular Answer

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

1
3/31/2017 6:25:21 AM


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