Ensuring the consistency of our aggregate is so important thing when developing web applications using DDD.
I worked in the past on a web application(no DDD) where we tried to ensure the consistency of our data using Transactions.So, We used Serializable transaction level and it was a nightmare for our team because the performance of our application was so bad and a lot of deadlocks issues have been reported by our users.
Now I am working on a web application implementing DDD principles and I need to ensure the consistency of our aggregates.
I have read here http://geekswithblogs.net/Optikal/archive/2013/04/07/152643.aspx that optimistic concurrency/locking is one of the methods to achieve that throw assigning a version or timestamp to our aggregate to check against it.
My first question is how to achieve optimistic concurrency using C# and entity framework in conjunction with Sql Server including the whole process from the beginning to the end, and where to store that column/flag if we take order and line items example which Eric Evans gave it in his book?
My second question is what are the common strategies used to ensure aggregates consistency in case of race conditions?
I would appreciate any code snippet or references.