Hi,
Is there a way in dotConnect for ORACLE and EF to have the key value be populated automatically from a SEQUENCE?
I don't have control over the tables so I can't add a trigger to do this.
I can probably figure out a way to extract the connection string from the EF model and create a normal ADO.NET connection to get the NEXTVAL and then populate it in my entity prior to saving...
But, it would be nice if there was a way to put it in the model.
Thank you! Great product!
Getting NEXTVAL from sequence
You have two alternatives.
The first way is to write three CommandTexts in the model for update, insert and delete (write the necessary SQL commands in these CommandTexts and map them as Insert/Update/Delete commands in the Configure Behaviour window).
The other way is to set the values for Entity Key using ADO.NET SQL command. Here is a simple way to get the store connection from ObjectContext:
The first way is to write three CommandTexts in the model for update, insert and delete (write the necessary SQL commands in these CommandTexts and map them as Insert/Update/Delete commands in the Configure Behaviour window).
The other way is to set the values for Entity Key using ADO.NET SQL command. Here is a simple way to get the store connection from ObjectContext:
Code: Select all
OracleConnection conn = (db.Connection as EntityConnection).StoreConnection as OracleConnection;