Hi,
I ran into the following problem: I have this legacy database with a table Foo. This table contains a technical Primary key ID.
In the past we called a stored procedure to get a range of ids from a sequence, assigned them and then persisted the rows in one batch insert.
Is there a way to override the key generation of a certain entity? So I can inject my own key generation algoritm?
Or is there a way change the entity keys before an insert takes place?
Thanks.
Best regards,
S
Entity keys: adding your own ids
I advise you either to make a trigger on inserting the row into the table and set the StoreGeneratedPattern property to Identity
or, as an alternative, to write a method calling the stored procedure returning the ids and then populate these ids
in the code before saving the entities.
As for your questions, there is no way to override the key generation, or the way to change the assigned Entity Key.
or, as an alternative, to write a method calling the stored procedure returning the ids and then populate these ids
in the code before saving the entities.
As for your questions, there is no way to override the key generation, or the way to change the assigned Entity Key.