[ACCEPTED]-why we use Concurrency Check Attribute in Entity Framework-entity-framework-4

Accepted answer
Score: 16

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 UPDATEs or DELETEs 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.

public class Account
    public Account() {}
    public int AccountID { get; set; }
    public string AccountName { get; set; } 

SQL Server will include 3 AccountName in UPDATEs or DELETEs 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'

This returns 2 no (zero) rows to the user because of the 1 concurrency check.

More Related questions