Devart.Data.Linq.ForeignKeyReferenceAlreadyHasValueException

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply
DomenicoFormoso
Posts: 8
Joined: Sat 06 Oct 2018 14:42

Devart.Data.Linq.ForeignKeyReferenceAlreadyHasValueException

Post by DomenicoFormoso » Wed 28 Nov 2018 08:59

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

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Devart.Data.Linq.ForeignKeyReferenceAlreadyHasValueException

Post by Shalex » Tue 04 Dec 2018 20:15

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.

Post Reply