we have some odd behavior when using optimistic concurrency in combination with datetime properties. Saving the context for the second time throws an OptimisticConcurrencyException.
Case:
(1) We have an object context with an entity type 'MASTER' and entity set 'MASTERSet'
(2) This MASTER entity has several properties, one of these properties is of a DateTime type. The property is mapped to an Oracle column of DATE type.
(3) All properties of the MASTER entity have been configured with a 'Fixed' concurrency mode.
(4) When we first set the the DateTime property and save the context everything goes wel. When we change some other property of the entity, the save fails with an OptimisticConcurrencyException. When we do not set the DateTime property the first time, the 2nd save doesn't fail.
Can anyone help us out with this strange problem?
This is the (VB.NET) code that demonstrates the problem:
Code: Select all
Using ctx As New SomeContext()
Try
Dim master As MASTER = (From m In ctx.MASTERSet Select m).First
master.SOMETEXTFIELD= "Test"
master.SOMEDATEFIELD= DateTime.Now
ctx.SaveChanges()
master.SOMETEXTFIELD= "TestUpdate"
ctx.SaveChanges() ' This save fails
Catch ex As Exception
System.Console.Out.WriteLine(ex.Message)
End Try
End Using
David