Hi
This may be very basic, but I have an entity with an auto generated Id, and a custom identificator that I want to follow the autogenerated id. My very old Mysql wont let me do this, so I've reverted to this strategy:
create entity
save entity and read the autogenerated id
write the autogenerated id to the other column
save the entity again
When I do that, it works. On my machine. And on our test server, but not on the production server. Test and production have individual but "identical" databases on the same database server.
In production the second "save the entity" will cause a
SD.LLBLGen.Pro.ORMSupportClasses.ORMQueryExecutionException: An exception was caught during the execution of an action query: Duplicate entry '10431-2022-01-21 15:37:29' for key 1. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception. ---> Devart.Data.MySql.MySqlException: Duplicate entry '10431-2022-01-21 15:37:29' for key 1
at Devart.Data.MySql.a1.a()
at Devart.Data.MySql.a1.h()
at Devart.Data.MySql.m.a(r[]& A_0, Int32& A_1, Boolean A_2)
at Devart.Data.MySql.m.a(Byte[] A_0, Int32 A_1, Boolean A_2, String A_3)
at Devart.Data.MySql.p.e()
at Devart.Data.MySql.MySqlCommand.InternalExecute(CommandBehavior behavior, IDisposable stmt, Int32 startRecord, Int32 maxRecords)
at Devart.Common.DbCommandBase.ExecuteDbDataReader(CommandBehavior behavior, Boolean nonQuery)
at Devart.Common.DbCommandBase.ExecuteNonQuery()
at SD.LLBLGen.Pro.ORMSupportClasses.ActionQuery.Execute()
--- End of inner exception stack trace ---
at SD.LLBLGen.Pro.ORMSupportClasses.ActionQuery.Execute()
at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterCore.ExecuteActionQuery(IActionQuery queryToExecute)
at SD.LLBLGen.Pro.ORMSupportClasses.ActionQueryController.ExecuteElements(List`1 elementsToRun)
at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterCore.PersistQueue(List`1 queueToPersist, Boolean insertActions)
at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterCore.SaveEntity(IEntity2 entityToSave, Boolean refetchAfterSave, IPredicateExpression updateRestriction, Boolean recurse)
at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.<>c__DisplayClass19_0.<SaveEntity>b__0()
The (relevant part) of the code:
var newCustomerProduct = new CustomerProductEntity
{
SubscriptionId = 0,
CustomerId = customerId,
... omitted for readability ...
};
adapter.SaveEntity(newCustomerProduct, true);
// creating a new customer product equals creating a new subscription, so set the subscription id to the id of the original customer product
newCustomerProduct.SubscriptionId = newCustomerProduct.Id;
adapter.SaveEntity(newCustomerProduct, true);
Am I doing something conceptually wrong, code-wise - or should I be looking for other issues? How can this suddenly not work....
- LLBLGen 5.8 (5.8.1) RTM Adapter template
- Mysql 5.6
- Devart dotconnect for MySQL express 8.19.1866.0
/Jan
Edit: we use Devart dotconnect 8.19.1866.0
Edit2: and 5.8.1, not 5.8.0