efcore icon indicating copy to clipboard operation
efcore copied to clipboard

ConcurrencyCheck not work

Open MohammadAkbari opened this issue 10 years ago • 1 comments

In following sample i use ConcurrencyCheck DataAnnotation for handling concurrency issues, but after executing add-migration command the Up and Down methods in the generated migration file are empty and when i run two sample of project concurrently (break point before SaveChanges method), there is no concurrency exception. and both updates affect on database.

public static void Main(string[] args)
{
    using (var dbContext = new ApplicationContext())
    {
        var company = dbContext.Companies.First();
        company.Name = "new name";
        dbContext.SaveChanges();
    }
    Console.ReadKey();
}

public class Company
{
    public int Id { get; set; }
    [ConcurrencyCheck]
    public string Name { get; set; }
    public Company Clone()
    {
        return (Company)this.MemberwiseClone();
    }
}

MohammadAkbari avatar Jul 27 '16 04:07 MohammadAkbari

How do you solve it?

Cuiqs76 avatar Apr 06 '17 06:04 Cuiqs76