From a foreign key in a table, EF does not construct a foreign key association.

entity-framework

Question

I have a table tblEvent and another table tblContact. There is a field ContactID in tblEvent that is linked by a foreign key to ContactID in tblContact. I've triple checked; the foreign key is in the database.

The Entity Framework model DOES NOT generate a navigation property and foreign key association for it as it does for the other foreign keys.

What could be different about this foreign key that EF does not generate a navigation property for it?

Thanks!

1
13
12/10/2010 9:27:05 AM

Popular Answer

I found the solution here:

Why doesn't EF 4 generate association for FK relation to column with unique index?

The reason it was not recognizing it is was because the table had a unique non-clustered index on the foreign key field.

Apparently, a unique, non-clustered index allows for a null value which can't be mapped.

12
5/23/2017 12:33:33 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