This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hello, I already asked this in another thread, but I think I was not clear enough, so here it goes again. I've downloaded a nightly build 3 days ago, so I could override the GeneratedId() method on some of my entities. I'm writing some database cloning routines, so I need to manually set IDs on the destination to match the source. Using the debugger, I found that GeneratedId() is working as it should, because when I call the Add() method on the unit of work, GeneratedId() is called and the added entities show the correct ID. However, after a call to SaveChanges(), I open the destination database (the ID field is an INTEGER in SQLite with no AUTOINCREMENT) and the IDs on the added records are sequential. For example, instead of 3, 5 and 12, they are 1, 2 and 3. Do you have any clue on why this is happening? Thanks. paulo |
|
|
Hello Paulo, Sorry for the delay in replying. We would expect this to happen only if the IdentityMethod was set to IdentityColumn. But since your ID column is not autoincrementing, we would expect IdentityColumn to fail (with a complaint about being unable to insert NULL into the ID column) rather than silently insert sequential values. Could you tell us what IdentityMethod you are using? Also, could you provide us with the SQLite DB3 file or the CREATE TABLE script that you used to create it? Thanks! |
|
|
Hello Ivan, You're right! I had IdentityMethod set to IdentityColumn because I copy-pasted the initialization from another piece of code. I just removed that line and everything is working right now! Thanks for your help. paulo |
|