c# - How can I remove a reference from an entity object to another entity with the Entity Framework? -


i have entity locations primary key consisting of longitude , latitude double.

from entity object want remove reference entity object in locations every time try set reference null optimisticconcurrencyexception.

using (mymodelcontainer context = new mymodelcontainer()) {     note note = context.notes.single(n => n.nid == noteupdate.nid);     note.locationreference.load();     note.locationreference = null;     context.savechanges(); } 

but not working. same note.locationreference.value = null.

how can set reference null or default value?

i believe purpose update db location column of note row set null here, detaching not going work. think replacing note.locationreference = null; note.location = null; in code above should work


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -