1

I'll try to explain my problem although to be honest I can't even understand it. After many changes in a couple of tables in my DB now I try to create a Foreign key and I'm getting this error when updating the EDMX.

gHOP.msl(410,10) : error 3007: Problem in Mapping Fragments starting at lines 410,
1511: Non-Primary-Key column(s) [UserGUID] 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.

gHOP.msl(1511,6) : error 3012: Problem in Mapping Fragments starting at lines 410, 1511: Data loss is possible in Itinerary.UserGUID. An Entity with Key (PK) will not round-trip when: (PK does NOT play Role 'Itinerary' in AssociationSet 'FK_Itinerary_Users' AND PK is in 'Itinerary' EntitySet)

gHOP.msl(410,10) : error 3012: Problem in Mapping Fragments starting at lines 410, 1511: Data loss is possible in Itinerary.UserGUID. An Entity with Key (PK) will not round-trip when: (PK is in 'Itinerary' EntitySet AND PK does NOT play Role 'Itinerary' in AssociationSet 'FK_Itinerary_Users' AND Entity.UserGUID is not NULL)

Honestly, it's been a nightmare because I can't understand what's going on. Although I've given up and I won't create the FK if someone could at least give me a hint I would really appreciate it.

Thanks

4
  • it seems wrong/non-primary-key columns are mapped as foreign key in a relationship. For relationship 'FK_Itinerary_Users', can you confirm one end is Primary key of a table? Commented May 31, 2012 at 8:45
  • Yes, UserGUID is PK im the Users table Commented May 31, 2012 at 8:48
  • can you give more details about table structure and PK and columns participating in foreignkey relation? Commented May 31, 2012 at 8:55
  • It seems to be quite straightforward , the UserGUID is the primary key in the USERS table and just a normal column in ITINERARY. Theres no other foreign key in the USERS there's one in the ITINERARY but not referred to the UserGUID column. The only problem I can only think is that there's another table, called EXtranetUsers with a UserGUID property, but I've changed the name and it didn't work. It may be an old problem, having not created properly the keys at first instance I guess Commented May 31, 2012 at 9:18

1 Answer 1

5

Not sure how much access/control you have over the model but I've encountered similar issues before when updating entities in the db and then attempting to update the model. I usually just delete the entities from the model which you edited in the db! Rebuild without them. Then re-add them after the build. I find that Visual Studio is not always successful updating the model when structural/relational changes have been made in the db.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks daveL, I have tried this and it builds and runs but after again I can't add the FK. I'll work it around just with the LINQ expressions in the code. I agree with you in regards to VS and the changes in the model

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.