Actually I am getting an exception
Conflicting changes to the role 'TableName' of the relationship 'DataModel.FK_TableName_RelateTableName' detected
when ApplyChanges method is called from the ObjectContext. I dont have any idea what this exception is all about. I just wanted to know the cause of this exception.
I think you get these sorts of exceptions if you are trying to get the foreign key relationship for the same entity twice. A simple example would be this:
var tn = ctx.TableName.Where(t => t.TableNameId == 1).First();
var rel = new RelateTableName {TableName = tn, TableNameId = 2};
ctx.RelateTableName.AddObject(rel);
Here you can see that I set the TableNameId property to 2 but the TableName property to an object with the TableNameId of 1 - so the entity framework cannot work out which one is the correct relationship to put into the database.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With