eXPerience
eXPerience

Reputation: 466

Entity Framework Concurrency token is added to insert query

My app is using postgres with EntityFramework6.Npgsql (DB first). I'm trying to resolve concurrency issue using xmin column hidden system column of postgres. I added it to c# model class like this:

public string xmin { get; set; }

Also added to edmx file. SSDL section

<Property Name="xmin" Type="text" Nullable="false" />

CSDL section

<Property Name="xmin" Type="text" Nullable="false" />

C-S section

<ScalarProperty Name="xmin" ColumnName="xmin" />

And specified the following parameters for this property in designer:

Concurrency Mode: Fixed
StoreGeneratedPattern: Computed

Now update commands work as expected, but EF adds this column into insert query as well and it throws exception about xmin column not being found.

Currently I use raw SQL as workaround

db.Database.ExecuteSqlCommand("INSERT INTO ...");

Is there a way to exclude this column from EF's insert query?

Upvotes: 0

Views: 81

Answers (0)

Related Questions