3

I have Table Field1 PK int not null Field2 PK int not null like this when i want to map this table I get this error

Error   3   Error 3034: Problem in mapping fragments starting at lines 2212, 2218:
Two entities with possibly different keys are mapped to the same row.
Ensure these two mapping fragments map both ends of the AssociationSet to the corresponding columns.

And I tried to delete and re-create that table inside model. When i add table it gives another error but at the end i always get this error

How can i handle this problem please help me...

saulyasar
  • 797
  • 1
  • 17
  • 45
  • there is no enough details in your question to answer it. Show the model and the mapping. – Pawel Feb 21 '14 at 19:06
  • @Pawel also i edit my problem how to solve it thank you for your feedback – saulyasar Feb 24 '14 at 07:47
  • @saul it's better to add answer(by yourself) to separate question and answer. – Søren Feb 24 '14 at 07:52
  • @Soren Yes but i dont have permission long answers for my account... :( – saulyasar Feb 24 '14 at 11:25
  • Fortunately I found your answer, thanks for adding it after you solved it (you should be able now to add an extra answer with a reputation of 66)! For me this problem occured when I modified my database (I had a m:n relationship) without foreign keys between person and books in a table person_books (so the designer created an object person_books). So I added FKs, then I uptated my model with the designer leading to book containing persons and person containing books. Removing the object person_books from the model solved the problem. – Verena Haunschmid Sep 09 '14 at 07:32

3 Answers3

3

When i investigate the problem, i realised something becuse i read an article before for this data model situation and i understand the why the problem occur. (Problem in mapping fragments in Entity Framework)

Actually problem comes from table mapping because i said that table has many to many relationship so That article says if you put that table in the model design it always gives us this error and finally when we delete that table on design side and add table silently in data model so program can be build. I ‘m telling you this because maybe you can make an idea for this because i learned this and when i add new view in model and vs doesnt give me any error.

This is the old model picture when the delete that table inside red box The program doesn't give any error and continiue to use bottom table

enter image description here

enter image description here

saulyasar
  • 797
  • 1
  • 17
  • 45
1

If nothing else works, try deleting and recreating the whole .edmx-file.

I got this problem when I added a couple of many-to-many tables to an existing Entity Framework 6.2 project. I tried removing and regenerating all tables in the model. Nothing seemed to work. I believe there was some "junk" somewhere in the EF project causing the problem.

When regenerating the edmx, I added all tables in the project, including the many-to-many tables.

andersh
  • 8,105
  • 6
  • 39
  • 30
0

solution for error:3034

PK UserId; PK RoleId

two primary key cannot allow edmx file.so create sno column in that table and make that as primary key . remove the pk of UserId and RoleId. now in that two column there is no primary key available.

like

Pk sno; FK UserId; FK RoleId

MOHAN RAJ P
  • 1
  • 1
  • 2
  • 6