[ACCEPTED]-why we use Concurrency Check Attribute in Entity Framework-entity-framework-4
It's a way to handle conflicts to database 14 changes when multiple users are updating 13 entities at the same time. Adding the ConcurrencyCheck
attribute 12 means that you are telling
Entity Framework 11 to use that property for detecting concurrency 10 conflicts. Entity Framework includes the 9 property in UPDATE
s or DELETE
s to the database.
For database 8 tables that have many columns this can mean 7 very large WHERE
clauses, which can affect performance 6 and require you to manage large amounts 5 of state. For larger databases a row version 4 strategy is preferred.
[Table("Accounts"]
public class Account
{
public Account() {}
[Key]
public int AccountID { get; set; }
[ConcurrencyCheck]
public string AccountName { get; set; }
}
SQL Server will include 3 AccountName
in UPDATE
s or DELETE
s to the database:
exec sp_executesql N'UPDATE [dbo].[Accounts]
SET [AccountName] = @0
WHERE (([AccountId] = @1) AND ([AccountName] = @2))
',N'@0 nvarchar(max) ,@1 int,@2 nvarchar(max) ',@0=N'Dick',@1=1,@2=N'Harry'
go
This returns 2 no (zero) rows to the user because of the 1 concurrency check.
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.