Page 1 of 1

Devart.Data.Linq.ForeignKeyReferenceAlreadyHasValueException

Posted: Wed 28 Nov 2018 08:59
by DomenicoFormoso
I have this code:

Code: Select all

WegDataContext db = new WegDataContext();
Fornisceforniamo ff = new Fornisceforniamo();
ff=db.Fornisceforniamos.FirstOrDefault(u => u.Idf == _idf && u.Ida == _ida && u.Ids==_ids);
ff.Ida = textIdA.Text;
ff.u = dataAgg.Value;
ff.p = p.Valore(); //my component
ff.Ids = (int)textS.Tag;    
db.SubmitChanges();
(Ids, Ida and Idf They are Entity Key)

at the line: ff.Ids = (int)textS.Tag;
I get this the error: Devart.Data.Linq.ForeignKeyReferenceAlreadyHasValueException.
I read other posts but I can not figure out how to fix this

Re: Devart.Data.Linq.ForeignKeyReferenceAlreadyHasValueException

Posted: Tue 04 Dec 2018 20:15
by Shalex
DomenicoFormoso wrote: Wed 28 Nov 2018 08:59

Code: Select all

ff.Ids = (int)textS.Tag;
Ids, Ida and Idf They are Entity Key
1. ORM framework doesn't allow modifying a primary key member of an entity.
DomenicoFormoso wrote: Wed 28 Nov 2018 08:59I get this the error: Devart.Data.Linq.ForeignKeyReferenceAlreadyHasValueException.
2. This error occurs before the main problem (1). Please send us a small test project with the corresponding DDL/DML script so that we can reproduce and investigate the issue.