ORA-02291 during saveChanges
Posted: Wed 15 Jul 2009 08:28
The database Model is this One
table PARAMETER_DEFINITION
paramaterId
parameterName
table PRODUCT
productId
productVersion
table PRODUCT_PARAMETER
parameterId
productId
productVersion
The Primary keys are bold
The table PRODUCT_PARAMETER has a foreign key with PARAMETER_DEFINITION and a foreign key with PRODUCT.
With Entity Framework (and DEVART) we try to create a new product with its new parameter (the parameterDefintion already exists).
Here is the code :
ProductionHandlerEntities EdmProduction = new ProductionHandlerEntities();
Product myProduct = Product.CreateProduct("MyProductId", "MyProductVersion");
EdmProduction.AddToProductSet(myProduct);
myProduct.Name = "MyProduct";
//Create a parameter which depends to MyProduct and to the parameterDefinition "ERP_CSV"
ProductParameter theProductParameter = ProductParameter.CreateProductParameter("ERP_CSV", myProduct.ProductId, myProduct.ProductVersion);
EdmProduction.AddToProductParameterSet(theProductParameter);
theProductParameter.ParameterDefinitionReference.EntityKey = ParameterDefinition.CreateParameterDefinitionKey("ERP_CSV");
myProduct.Parameters.Add(theProductParameter);
EdmProduction.SaveChanges();
This code fails with :
System.Data.UpdateException: An error occurred while updating the entries. See the InnerException for details. ---> Devart.Data.Oracle.OracleException: ORA-02291: integrity constraint (PRODUCIM.FK1_AFFECT_PRM_PROD) violated - parent key not found
The FK1_AFFECT_PRM_PROD is the foreign key between ProductParameter and product.
It seems that "devart entity framework" try to insert into PRODUCT_PARAMETER before into PRODUCT.
Thanks for your help
Pierre Jourdat
table PARAMETER_DEFINITION
paramaterId
parameterName
table PRODUCT
productId
productVersion
table PRODUCT_PARAMETER
parameterId
productId
productVersion
The Primary keys are bold
The table PRODUCT_PARAMETER has a foreign key with PARAMETER_DEFINITION and a foreign key with PRODUCT.
With Entity Framework (and DEVART) we try to create a new product with its new parameter (the parameterDefintion already exists).
Here is the code :
ProductionHandlerEntities EdmProduction = new ProductionHandlerEntities();
Product myProduct = Product.CreateProduct("MyProductId", "MyProductVersion");
EdmProduction.AddToProductSet(myProduct);
myProduct.Name = "MyProduct";
//Create a parameter which depends to MyProduct and to the parameterDefinition "ERP_CSV"
ProductParameter theProductParameter = ProductParameter.CreateProductParameter("ERP_CSV", myProduct.ProductId, myProduct.ProductVersion);
EdmProduction.AddToProductParameterSet(theProductParameter);
theProductParameter.ParameterDefinitionReference.EntityKey = ParameterDefinition.CreateParameterDefinitionKey("ERP_CSV");
myProduct.Parameters.Add(theProductParameter);
EdmProduction.SaveChanges();
This code fails with :
System.Data.UpdateException: An error occurred while updating the entries. See the InnerException for details. ---> Devart.Data.Oracle.OracleException: ORA-02291: integrity constraint (PRODUCIM.FK1_AFFECT_PRM_PROD) violated - parent key not found
The FK1_AFFECT_PRM_PROD is the foreign key between ProductParameter and product.
It seems that "devart entity framework" try to insert into PRODUCT_PARAMETER before into PRODUCT.
Thanks for your help
Pierre Jourdat