So I set up an Sqlite In memory database for my unit testing.
I'm planning to copy constants/lookups from the real database to the in memory one.
I got stuck when inserting the records to the in memory dabase.
List<SqlLookup> lookups;
using(var session = new DataSession()) {
lookups = session.QueryOver<SqlLookup>().List()
}
using (var session = new InMemoryDataSession()) {
session.Merge(lu);
}
- Problem is that even if the original data has Id already set, it is not saved to the db. Nhibernate still generates an auto incremented one
- Since new Id's are being saved, the mappings are updated and an exception is thrown when updating an old record id that has been used.
{"Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect)
Is there a workaround for this?
If not, is this the right way to seed these constant data to my in memory database?
Are there other solutions asides from running SQL scripts of the data? Maintaining hundreds of lookup scripts would be hard.
Thank you.
Aucun commentaire:
Enregistrer un commentaire