Skip to Main Content

ODP.NET

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to get DbUpdateConcurrencyException in Entity Framework 6

e3ec722d-8292-4336-ae0e-f08a7e74ef5fJun 8 2016 — edited Jun 8 2016

I have a trigger set on the "Timestamp" field as fallows:

CREATE OR REPLACE TRIGGER M_User_TRIG BEFORE INSERT OR UPDATE ON "M_User"

FOR EACH ROW

BEGIN

  :new."Timestamp" := SYSTIMESTAMP;

END;

In Entity Framework 6 the "Timestamp" field has the following propertyies:

StoreGeneratedPattern: Computed

Concurrency Mode: Fixed

I can't get a DbUpdateConcurrencyException, instead I got a DbUpdateException as follows:

"A null store-generated value was returned for a non-nullable member 'Timestamp' of type 'EntityModel.M_User'."

--------------------------------------------------------------------------------

Here is the SQL generated by Entity Framework 6:

--------------------------------------------------------------------------------

declare

"Timestamp" timestamp;

begin

update "EF_DEV"."M_User"

set "ShowName" = :p0

where (("ID" = :p1) and ("Timestamp" = :p2))

returning

"Timestamp" into

"Timestamp";

open :p3 for select

"Timestamp" as "Timestamp" from dual;

end;

-- :p0: 'Benny' (Type = String, Size = 20)

-- :p1: '21' (Type = Int64)

-- :p2: '2016/06/07 10:20:35' (Type = DateTime)

-- :p3: 'null' (Type = Object, Direction = Output, IsNullable = false)

--------------------------------------------------------------------------------

But it works perfectly in MS SQL Server,

and here is the SQL generated by Entity Framework 6:

--------------------------------------------------------------------------------

UPDATE [dbo].[M_User]

SET [ShowName] = @0

WHERE (([ID] = @1) AND ([Timestamp] = @2))

SELECT [Timestamp]

FROM [dbo].[M_User]

WHERE @@ROWCOUNT > 0 AND [ID] = @1

-- @0: 'Benny2' (Type = String, Size = 20)

-- @1: '1020000002' (Type = Int64)

-- @2: 'System.Byte[]' (Type = Binary, Size = 8)

--------------------------------------------------------------------------------

Had any solution to get a DbUpdateConcurrencyException, not a DbUpdateException in Entity Framework 6,

because I need to check concurrency problem and reload the concurrency exception row.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 6 2016
Added on Jun 8 2016
0 comments
1,132 views