I have an instance of TPM_PROJECTVERSION
called projectVersion
, which has a property called TPM_USER5
which is of type TPM_USER
. A TPM_PROJECTVERSION
can have zero or one TPM_USER5
references (Sorry, I didn't come up with these names.)
When the user clicks a Delete button, I want to remove this reference, thus setting the column in the database to null. I've tried the following:
projectVersion.TPM_USER5 = null;
However, when I call context.SaveChanges()
, the column is not updated and nothing happens. Under the debugger, I can see that projectVersion.TPM_USER5
is indeed null, and I also see that projectVersion.TPM_USER5Reference.IsLoaded
is true. I've also tried:
context.DeleteObject(projectVersion.TPM_USER5);
If I do this, when I call context.SaveChanges()
, I get the exception:
{"ORA-02292: integrity constraint (TPMDBO.TPM_PROJECTCHANGES_TPM_US_FK1) violated - child record found"}
I'd be happy to post more information about the entity mappings, but not sure exactly what's relevant. Any ideas?
If I understand correctly thus you removing only navigation property (TPM_USER5). Try set primitive property (TPM_USER5ID? - probably your db column name) to null.
Each navigation property must have relevant primitive property (not POCO entities) and you can use both to associate user to TPM_USER5 (primitive property - set id, navigation property - set reference).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.