Xid column type support

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
Posts: 1
Joined: Mon 14 Jan 2013 15:47

Xid column type support

Post by omatrot » Tue 15 Jan 2013 15:13


I'm working with Npgsql provider and Entity Framework 5 with PostgreSQL 9.X, but we have so much problems with the System.Transaction support in this provider that we are in the process of evaluating dotConnect for PostgreSQL.

With Npgsql, I could include the hidden xmin column (of type XID) that is available on every table to enable Optimistic concurrency.

In my model, this column is set to be :

SSDL : <Property Name="xmin" Type="bigint" StoreGeneratedPattern="Computed" />
CSDL : <Property Name="xmin" Type="Int64" Nullable="false" p1:StoreGeneratedPattern="Computed" ConcurrencyMode="Fixed" p9:SetterAccess="Internal" xmlns:p9="http://schemas.microsoft.com/ado/2006/04/codegeneration" />

At runtime with dotConnect for PostgreSQL there is an exception while issuing a simple query on the entity :

Code: Select all

System.InvalidOperationException: The 'xmin' property on 'Person' could not be set to a 'String' value. You must set this property to a non-null value of type 'Int64'. 
   at System.Data.Common.Internal.Materialization.Shaper.ErrorHandlingValueReader`1.GetValue(DbDataReader reader, Int32 ordinal)
   at System.Data.Common.Internal.Materialization.Shaper.GetPropertyValueWithErrorHandling[TProperty](Int32 ordinal, String propertyName, String typeName)
   at lambda_method(Closure , Shaper )
   at System.Data.Common.Internal.Materialization.Coordinator`1.ReadNextElement(Shaper shaper)
   at System.Data.Common.Internal.Materialization.Shaper`1.SimpleEnumerator.MoveNext()
Could you please explain what is happening here ?

By the way, If by any chance this problem is overcomed, I may have propbably another issue. The provider must return computed column with statements like "INSERT ... RETURNING xmin,..." and "UPDATE ... RETURNING xmin,..." otherwise, this will not work as the transaction id will be incorrect.

Is it the case ?

Any help appreciated.
Thanks in advance.

Site Admin
Posts: 8247
Joined: Thu 14 Aug 2008 12:44

Re: Xid column type support

Post by Shalex » Mon 21 Jan 2013 11:38

omatrot wrote:The 'xmin' property on 'Person' could not be set to a 'String' value. You must set this property to a non-null value of type 'Int64'.
Open your model with Entity Developer (it allows to modify both CSDL and SSDL in design time) and check settings for xmin column:
SSDL - Name=xmin, Store Generated Pattern=Computed, Type=bigint
CSDL - Name=Xmin, Store Generated Pattern=Computed, Type=Int64, Nullable=False, Concurrency Mode=Fixed Setter=Internal

After this, the record is successfully added in our test project with the following SQL:
INSERT INTO public.dept(deptno, dname, loc)
VALUES (:p0, :p1, :p2)

Post Reply