Entity Framework model and foreign key property
Posted
by verror
on Stack Overflow
See other posts from Stack Overflow
or by verror
Published on 2010-05-02T07:47:59Z
Indexed on
2010/05/02
7:57 UTC
Read the original article
Hit count: 234
c#
|entity-framework
I have 2 tables that I import to EF model.
First table has a property [section] that acts as foreign key to the second table.
When I map this property in model to the table and try to compile I get this error:
Problem in Mapping Fragments starting at lines 158, 174: Non-Primary-Key column(s) [Section] are being mapped in both fragments to different conceptual side properties - data inconsistency is possible because the corresponding conceptual side properties can be independently modified.
If i remove this property from the model it passes, but when I query the data I don't have the section field.
I know that I can get it by using the navigation field and reading this property from the second table, but to make it work I must include the other table in my query.
var res = from name in Context.Table1.Include("Table2")...
Why do I need to include the association just for one field?
© Stack Overflow or respective owner