ORA 02291 integrity constraint violated-parent key not found
Posted: Wed 03 Jun 2020 08:25
Hello,
im am using Visual studio 2019, .NET Core 3.1 and devart.data.oracle.efcore (9.11.980).
I get the Error ORA-02291, when i am trying to save values in two Tables with dependencies.
For Example:
The Properties ID from TABLEA and TABLEB are generated in the Oracle-Database.
TABLEB.ID_TABLEA is linked to TABLEA.ID
using (Data.Model context = new Data.Model())
{
TABLEA newRowA = new TABLEA();
newRowA.TEXT = "hy";
context.TABLEA.Add(newRowA);
TABLEB newRowB = new TABLEB();
newRowB.ID_TABLEA = newRowA.ID;
context.TABLEB.Add(newRowB);
context.SaveChanges() > ERROR 02291
}
The ID-Properties of both Tables ar set to Value Generated "OnAdd".
When i perform context.SaveChanges() after adding TABLEA the ID is generated and i can save TABLEB.
But when one insert fails, then nothing should be in the Database.
That is not an Option in this case.
Thanks for your help.
Roman
im am using Visual studio 2019, .NET Core 3.1 and devart.data.oracle.efcore (9.11.980).
I get the Error ORA-02291, when i am trying to save values in two Tables with dependencies.
For Example:
The Properties ID from TABLEA and TABLEB are generated in the Oracle-Database.
TABLEB.ID_TABLEA is linked to TABLEA.ID
using (Data.Model context = new Data.Model())
{
TABLEA newRowA = new TABLEA();
newRowA.TEXT = "hy";
context.TABLEA.Add(newRowA);
TABLEB newRowB = new TABLEB();
newRowB.ID_TABLEA = newRowA.ID;
context.TABLEB.Add(newRowB);
context.SaveChanges() > ERROR 02291
}
The ID-Properties of both Tables ar set to Value Generated "OnAdd".
When i perform context.SaveChanges() after adding TABLEA the ID is generated and i can save TABLEB.
But when one insert fails, then nothing should be in the Database.
That is not an Option in this case.
Thanks for your help.
Roman