I get the Exception "Can not insert entity with the same key if key is not database generated". I am using dotConnect for Oracle version 6.70.
If records were not deleted first I would expect to get this error, since it would be a duplicate key.
But I delete records first, so the record I am about to create is brand new record, and PK IS NOT REPEATING since it is already deleted.
below is my code (simplified):
Code: Select all
using (DbTransaction transaction = DB.Connection.BeginTransaction()) {
// first I delete set of rows from comp_Style table
context.ExecuteCommand("DELETE FROM comp_Style WHERE job_num = 1");
......
// later on in a code I recreate the rows I deleted
CompStyle styleDB = new CompStyle();
styleDB.CounterId = counterID;
// CounterId is Primary Key, I am reusing the same ID(counterID) from the record I deleted previously
context.CompStyles.InsertOnSubmit(styleDB);
// this is when I get the exception
}