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
ORA-02291 during saveChanges
Any progress on the ORA-02291 error with SaveChanges?
I have encountered exactly the same problem described in the post by PJourdat. When creating a new master record and a new related detail record using EntityFramework, I get the ORA-02291 error when calling SaveChanges.
When I retrieve a previously saved master record and create a new related detail record, everything goes as expected.
Any new suggestions on this? I am willing to specify additional information if necessary. Please let me know.
Thanks!
Hennie Gottenbos.
When I retrieve a previously saved master record and create a new related detail record, everything goes as expected.
Any new suggestions on this? I am willing to specify additional information if necessary. Please let me know.
Thanks!
Hennie Gottenbos.
Hennieg, have you tried the latest 5.25.42 build of dotConnect for Oracle? If the problem persists with the 5.25.42 build too, please send us (http://www.devart.com/company/contact.html) a small test project with the script of db objects. We cannot reproduce the issue.
Problem solved using StoreGeneratedPattern="Identity"
Strange that you could not reproduce this problem. I found mention of similar problems in the Devart forums related to IDs generated by the database using a trigger and a sequence. Manually adding StoreGeneratedPattern="Identity" tag to the Property elements for the ID fields of both the master and the detail records in the .edmx file solved the problem.
This does however mean this manual addition needs to be done whenever the model is regenerated after working in the EF Designer. Not really a viable solution for large projects. Hopefully a more structured solution will become available in due course.
To be clear: I did try 5.25.42 build but this did not solve the problem. The use of the StoreGeneratedPattern tag was still necessary.
Best,
Hennie.
This does however mean this manual addition needs to be done whenever the model is regenerated after working in the EF Designer. Not really a viable solution for large projects. Hopefully a more structured solution will become available in due course.
To be clear: I did try 5.25.42 build but this did not solve the problem. The use of the StoreGeneratedPattern tag was still necessary.
Best,
Hennie.
The situation is rather difficult.
First, Oracle does not have any mechanism to indicate that the column is an autoincrement one, unlike other databases
(SQL Server's Identity column, for example, or MySQL auto_increment).
But Entity Framework should be aware of it, that's why there is a need to set StoreGeneratedPattern to "Identity".
Microsoft Update model from database wizard overwrites all manual changes.
Unfortunately we cannot change this behaviour.
As an alternative, try to use Devart Entity Developer. It gives limited opportunities to update,
but you are able to add new entities to the model, and the manual changes are preserved.
First, Oracle does not have any mechanism to indicate that the column is an autoincrement one, unlike other databases
(SQL Server's Identity column, for example, or MySQL auto_increment).
But Entity Framework should be aware of it, that's why there is a need to set StoreGeneratedPattern to "Identity".
Microsoft Update model from database wizard overwrites all manual changes.
Unfortunately we cannot change this behaviour.
As an alternative, try to use Devart Entity Developer. It gives limited opportunities to update,
but you are able to add new entities to the model, and the manual changes are preserved.