Problem with displaying fragments in Entity Framework

I am using the framework entity and I encountered an odd build error.

I create a forum, and I created a table in the database to “ignore”, when people do not like each other, they will ignore someone. A table has two columns, and together they are primary keys.

PK InitiatingUser PK IgnoredUser 

When EF displays this table, I get this error:

Error 7 Error 3034: Problem with displaying fragments starting from lines 1467, 1477: Two objects with different keys are displayed on the same line. Make sure that these two display fragments map both ends of the AssociationSet to the appropriate columns.

I opened edmx in an xml editor and switched to breaking lines.

  <MappingFragment StoreEntitySet="Ignores"> <ScalarProperty Name="IgnoredUser" ColumnName="IgnoredUser" /> <ScalarProperty Name="InitiatingUser" ColumnName="InitiatingUser" /> </MappingFragment> 

I am just starting with EF and I don’t understand what is happening or what might be the problem.

Any help is appreciated.

EDIT Relationships between ignored keys used to have foreign keys that map both the initiating user and the ignored user to the primary key (username) of the user table. That was when I first matched EF with this table. Since then I have removed FK to see if this helps, but it doesn’t.

+12
entity-framework entity-relationship entity-framework-4
source share
3 answers

I don’t know what is wrong here, but I just deleted the table from ORM and the DB, and then recreated it with the actual identifier column instead of the two primary keys. I re-rendered the table, compiled it, and now everything is fine. It would be convenient to do it the way I do, but good.

If anyone knows, let me know. I would prefer someone to answer.

+5
source share

This is probably due to the inclusion of a many-to-many join table in your entity model or what EF considers to be such a table (perhaps one that does not have its own autonomous key, but whose identity consists of two or more foreign keys) .

So let's say you have the following tables:

  • Person
  • Address
  • PersonAddress (contains only PersonID and AddressID)

In your entity model, you should add only the person and address. If you add PersonAddress then EF will throw an error. According to this MSDN Q&A , EF automatically considers the connection table.

+28
source share

PC InitiatingUser; PC IgnoredUser

the two primary keys cannot allow edmx file.so to create the sno column in this table and make it the primary key. Remove PC from InitiatingUser and IgnoredUser. now in these two columns there is no primary key available.

like

Pc sleep; FK InitiatingUser; PC IgnoredUser

0
source share

All Articles