I have entity structure like this: base class EntityBase with Key field Id (type of long) child classes: Person and Material both are inherited from EntityBase i have copied sql database from one pc to another (by sql export procedure) and as a result (after some time program work and creates some entities) i have a situation when dbo.Person and dbo.Material tables contains rows with same Id 1921. Now when i'm trying to query for Session.Query.Single<person>(1921) - this code throws exception:
stacktrace:
So my question is: where does DO stores information about last Key (ID) generated and how can i eliminate the situation when two different types of entities inherited from the same base entity class can have same Id? My DO version is 4.5.5. |
Hello Dmitry F. According to key providing behavior keys of two entity can't be the same. I thing something went wrong when you did export procedure. Generally, keys are generated by special table in database which name is <name of="" keys'="" type="">-Generator or some custom name for custom generators. It have only one field with auto increment. Sometimes if DBMS supports sequences then DO use it. As I know, DO uses sequences for MS SQL Server 2012 and PostgreSql and Oracle. I suppose something happened with generator table or sequence. You can define key generator parameters in domain configuration. Using AppConfig in <domain> element:
or using DomainConfiguration.KeyGenerators collection
|