efcore
efcore copied to clipboard
ConcurrencyCheck not work
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();
}
}
How do you solve it?