exceção de simultaneidade otimista do Entity Framework não está ocorrendo

Temos um aplicativo ASP.Net MVC que usa o EF4 como sua camada de acesso a dados e estamos vendo um comportamento inesperado em relação ao OptimisitcConcurrencyExceptions não sendo lançado quando achamos que deveria se

Simplificamos o problema até o seguinte código ...

   using System.Linq;
    using Project.Model;

    namespace OptimisticConcurrency
    {
        class Program
        {
            static void Main()
            {
                Contact firstContact = null;
                using (var firstEntities = new ProjectEntities())
                {
                    firstContact = (from c in firstEntities.Contacts 
                       where c.LastName == "smith" select c).Single();
                }

                using (var secondEntities = new ProjectEntities())
                {
                    var secondContact = (from c in secondEntities.Contacts 
                       where c.LastName == "smith" select c).Single();

                    secondContact.Title = "a";
                    secondEntities.SaveChanges();
                }

                firstContact.Title = "b";

                using (var thirdEntities = new ProjectEntities())
                {
                    var thirdContact = (from c in thirdEntities.Contacts 
                       where c.LastName == "smith" select c).Single();

                    thirdContact.Title = firstContact.Title;

                    //EXPLICITLY SET VERSION HERE
                    thirdContact.Version = firstContact.Version;  

                    thirdEntities.SaveChanges();
                }
            }
        }
    }

sta é uma versão bastante simples do que acontece em nosso aplicativo MVC, mas o mesmo problema ocorr

Quando chamamos SaveChanges nas thirdEntities, espero a exceção e nada está sendo lançad

Muito mais interessante, quando anexamos o SQL Profiler, vemos que a versão está sendo usada na cláusula where, mas é o terceiro valor da versãoEntities (o atual no banco de dados) sendo usado, e não o valor firstEntities, apesar de ser definido explicitamente imediatamente antes de SaveChanges ser chamado. SaveChanges está redefinindo a versão para que seja o valor recuperado e não o valor definid

No EDMX, a versão está definida para ter um StoreGeneratedPattern definido como computad

Alguém tem alguma idéia do que está acontecendo aqui?

questionAnswers(1)

yourAnswerToTheQuestion