Hi I have two projects that use the same database to insert data. One is an MVC project, the other is a Functional Test Project. they both reference a third project just for my models. I use a dedicated key generated on one of the tables, if I insert a record into the table via the test project and do the same on the web project, I get a key violation exception, which means that both sessions are inserting the record with the same key. Is there any way to avoid key overlapping on different sessions created by different domains, even though the use the same configuration? regards Jamal |
Hi Denis, my model is something like this
my web.config in the web project is
and I build the domain using the code
the functional test project has an app.config file with the same configuration for my domain
and uses the same code above to build the domain. Then I run the web application with ctrl + F5 (Start without debugging) So I can have the process running. And run my test project to create a new user
So at this stage I have two processes running and accessing the same database. Now if I use my web project to create a user too, when I try to complete the transaction, it gives me an exception saying that A key violation occurred, so the session used by the web project tries to create a user with the same key as that created by the functional test. So the question is Shouldn't each process receive a different set of keys to work with? How does DO handles key generation if more than one process is accessing the same database? I've also noticed that at some point all the keyGeneration tables in my DB are cleaned. By profiling my DB I got lines like that DELETE FROM [dbo].[UserGenerator-Generator]; Is this normal? regards, Jamal |
Hello Jamal, could you provide your revelant persistent model parts? Code to create entity that causes this error would be useful as well!