DbUpdateConcurrencyException when using Devart dotConnect (9.5.454.0) with Oracle in EF Code First
DbUpdateConcurrencyException when using Devart dotConnect (9.5.454.0) with Oracle in EF Code First
I have an entity class in which few columns have IsConcurrencyToken() configuration defined on them.
For most of entites IsConcurrencyToken() is defined on column type DATE.
Ex: this.Property(t => t.column_name).HasColumnName("column_name").HasColumnType("DATE").IsConcurrencyToken();
Any save operation on this object is resulting in DbUpdateConcurrencyException.
I was able to save the object if i remove IsConcurrencyToken() on defined columns though.
I am facing this issue after migrating from Devart dotConnect 8.5.616 to 9.5.454.0; same scenario is working fine with Devart dotConnect (V 8.5.616.0)
Below are the exception details:
An exception of type 'System.Data.Entity.Infrastructure.DbUpdateConcurrencyException' occurred and was caught.
Type : System.Data.Entity.Infrastructure.DbUpdateConcurrencyException, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Message : Store update, insert, or delete statement affected an unexpected number of rows (0). Entities may have been modified or deleted since entities were loaded.
Any help on this is highly appreciated.
Thanks.
For most of entites IsConcurrencyToken() is defined on column type DATE.
Ex: this.Property(t => t.column_name).HasColumnName("column_name").HasColumnType("DATE").IsConcurrencyToken();
Any save operation on this object is resulting in DbUpdateConcurrencyException.
I was able to save the object if i remove IsConcurrencyToken() on defined columns though.
I am facing this issue after migrating from Devart dotConnect 8.5.616 to 9.5.454.0; same scenario is working fine with Devart dotConnect (V 8.5.616.0)
Below are the exception details:
An exception of type 'System.Data.Entity.Infrastructure.DbUpdateConcurrencyException' occurred and was caught.
Type : System.Data.Entity.Infrastructure.DbUpdateConcurrencyException, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Message : Store update, insert, or delete statement affected an unexpected number of rows (0). Entities may have been modified or deleted since entities were loaded.
Any help on this is highly appreciated.
Thanks.
Re: DbUpdateConcurrencyException when using Devart dotConnect (9.5.454.0) with Oracle in EF Code First
We have sent a test project to you. Please modify it for reproducing and upload to some file exchange server.
Re: DbUpdateConcurrencyException when using Devart dotConnect (9.5.454.0) with Oracle in EF Code First
I have not received any test project on my registered mail ID.
If possible can you resend it again and let me know how to send it back after modification.
Thanks.
If possible can you resend it again and let me know how to send it back after modification.
Thanks.
Re: DbUpdateConcurrencyException when using Devart dotConnect (9.5.454.0) with Oracle in EF Code First
I found exact root cause for this issue :
With devart dotConnect(V 9.5.454.0) Insert/Update/Select operations on oracle DB column of type TIMESTAMP the milliseconds value retrieved/updated as Zero's(Ex:10-Sep-02 14:10:10.000000) instead of actual value.
It is not possible to share sample application but i can post the steps to reproduce the issue:
1. Create table with at-least one column of type TIMESTAMP and insert sample data into it. PFB script :
create table sample(ID number(12),NAME varchar2(32),AMOUNT number(12),DOJ TIMESTAMP)
insert into sample values(1,'test data',100,systimestamp)
2. Define an entity and configure DOJ column with IsConcurrencyToken()
Ex: protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Sample>()
.Property(b => b.DOJ)
.HasColumnName("DOJ").IsConcurrencyToken();
}
3. Update amount column of sample table
Ex: var data =DbContext.Set<Sample>().Where(t => t.Id == 1).FirstOrDefault();
data.Amount = 200;
DbContext.Entry(data).State = EntityState.Modified;
DbContextContext.SaveChanges();
Upon performing update operation on column using devart dotConnect(V 9.5.454.0) it throws below exception:
Exception : Store update, insert, or delete statement affected an unexpected number of rows (0). Entities may have been modified or deleted since entities were loaded.
Same scenario is working fine with Devart dotConnect (V 8.5.616.0)
Please let me know the resolution at earliest.
Thanks.
With devart dotConnect(V 9.5.454.0) Insert/Update/Select operations on oracle DB column of type TIMESTAMP the milliseconds value retrieved/updated as Zero's(Ex:10-Sep-02 14:10:10.000000) instead of actual value.
It is not possible to share sample application but i can post the steps to reproduce the issue:
1. Create table with at-least one column of type TIMESTAMP and insert sample data into it. PFB script :
create table sample(ID number(12),NAME varchar2(32),AMOUNT number(12),DOJ TIMESTAMP)
insert into sample values(1,'test data',100,systimestamp)
2. Define an entity and configure DOJ column with IsConcurrencyToken()
Ex: protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Sample>()
.Property(b => b.DOJ)
.HasColumnName("DOJ").IsConcurrencyToken();
}
3. Update amount column of sample table
Ex: var data =DbContext.Set<Sample>().Where(t => t.Id == 1).FirstOrDefault();
data.Amount = 200;
DbContext.Entry(data).State = EntityState.Modified;
DbContextContext.SaveChanges();
Upon performing update operation on column using devart dotConnect(V 9.5.454.0) it throws below exception:
Exception : Store update, insert, or delete statement affected an unexpected number of rows (0). Entities may have been modified or deleted since entities were loaded.
Same scenario is working fine with Devart dotConnect (V 8.5.616.0)
Please let me know the resolution at earliest.
Thanks.
Re: DbUpdateConcurrencyException when using Devart dotConnect (9.5.454.0) with Oracle in EF Code First
We cannot reproduce the problem. We have asked for the additional information by email.
Re: DbUpdateConcurrencyException when using Devart dotConnect (9.5.454.0) with Oracle in EF Code First
I have not received any mail regarding this. please let me know in post if any additional information required.
Below are the steps to replicate issue easily :
1. create a table in oracle DB using this script
create table sample(ID number(12),DOJ TIMESTAMP)
2.Insert a record in to table with EF code first with both dotConnect versions
with version 9.5.454.0 DOJ column value will be inserted as: Ex:10-Sep-02 14:10:10.000000
with version 8.5.616.0 DOJ column value will be inserted as: Ex:10-Sep-02 14:10:10.458956
Milliseconds value will be inserted as zero with 9.5.454.0 and even with latest version 9.5.520
3. Even when we try to retrieve value of DOJ column Milliseconds value retrieved as zero's with 9.5.454.0
Thanks.
Below are the steps to replicate issue easily :
1. create a table in oracle DB using this script
create table sample(ID number(12),DOJ TIMESTAMP)
2.Insert a record in to table with EF code first with both dotConnect versions
with version 9.5.454.0 DOJ column value will be inserted as: Ex:10-Sep-02 14:10:10.000000
with version 8.5.616.0 DOJ column value will be inserted as: Ex:10-Sep-02 14:10:10.458956
Milliseconds value will be inserted as zero with 9.5.454.0 and even with latest version 9.5.520
3. Even when we try to retrieve value of DOJ column Milliseconds value retrieved as zero's with 9.5.454.0
Thanks.
Re: DbUpdateConcurrencyException when using Devart dotConnect (9.5.454.0) with Oracle in EF Code First
You should map the DOJ column type explicitly: .HasColumnType("timestamp");
After this, the DOJ column in database will have milliseconds information.
Re: DbUpdateConcurrencyException when using Devart dotConnect (9.5.454.0) with Oracle in EF Code First
Actually, the DateTime properties should be mapped to timestamp by default if you do not specify config.CodeFirstOptions.UseDateTimeAsDate=true; in your code explicitly (default value is False).
Re: DbUpdateConcurrencyException when using Devart dotConnect (9.5.454.0) with Oracle in EF Code First
If this doesn't help:
a) download https://www.devart.com/pub/259376_ticket.zip. Open the project in Visual Studio, right click *.edml > Open With > Entity Developer. Then navigate to Tools > Entity Developer > Database Explorer and Edit Connection Properties to adjust them to your environment. Save the *.edml. Run the code. Does the error occur? If necessary, modify it and upload to some file exchange server and give us the download link
b) specify your connection string (roughly, without credentials)
c) tell us the version (x.xx) of your Oracle Server
a) download https://www.devart.com/pub/259376_ticket.zip. Open the project in Visual Studio, right click *.edml > Open With > Entity Developer. Then navigate to Tools > Entity Developer > Database Explorer and Edit Connection Properties to adjust them to your environment. Save the *.edml. Run the code. Does the error occur? If necessary, modify it and upload to some file exchange server and give us the download link
b) specify your connection string (roughly, without credentials)
c) tell us the version (x.xx) of your Oracle Server
Re: DbUpdateConcurrencyException when using Devart dotConnect (9.5.454.0) with Oracle in EF Code First
I have mapped DOJ column as TIMESTAMP explicitly even then milliseconds value is saved/retrieved as zero's.
modelBuilder.Entity<Sample>()
.Property(b => b.DOJ)
.HasColumnName("DOJ").HasColumnType("timestamp").IsConcurrencyToken();
}
I will modify sample application that was shared with me to replicate the issue and share the same with you asap.
thanks.
Re: DbUpdateConcurrencyException when using Devart dotConnect (9.5.454.0) with Oracle in EF Code First
We have reproduced the difference in behavior between v8.5 and v9.5, it is caused by missing .Precision(6) in mapping.
We will notify you about the result of our investigation.
We will notify you about the result of our investigation.
Re: DbUpdateConcurrencyException when using Devart dotConnect (9.5.454.0) with Oracle in EF Code First
There is no timeframe for the fix of mapping with missing .Precision(6).
Please use a workaround with setting .Precision(6) for the timestamp columns. You can implement this workaround for all DateTime properties of a current context in the end of the OnModelCreating method via simple convention:
Please use a workaround with setting .Precision(6) for the timestamp columns. You can implement this workaround for all DateTime properties of a current context in the end of the OnModelCreating method via simple convention:
Code: Select all
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
// ...
modelBuilder.Properties<DateTime>()
.Configure(p => p.HasPrecision(6));
}
Re: DbUpdateConcurrencyException when using Devart dotConnect (9.5.454.0) with Oracle in EF Code First
Hi,
I have the same problem even with the last version of DotConnect for Oracle and EF 6.4.4 and using didn't help.
Is there another solution ?
I have the same problem even with the last version of DotConnect for Oracle and EF 6.4.4 and using
Code: Select all
modelBuilder.Properties<DateTime>().Configure(p => p.HasPrecision(6));
Is there another solution ?
-
- Posts: 1
- Joined: Mon 18 Jul 2022 12:08
Re: DbUpdateConcurrencyException when using Devart dotConnect (9.5.454.0) with Oracle in EF Code First
I have not received any mail regarding this. please let me know in post if any additional information required.
Re: DbUpdateConcurrencyException when using Devart dotConnect (9.5.454.0) with Oracle in EF Code First
Code: Select all
// DDL
// create table sample(ID number(12) primary key, NAME varchar2(32), AMOUNT number(12), DOJ TIMESTAMP);
using (var context = new MyDbContext()) {
var data = new SAMPLE() { ID = 1, DOJ = DateTime.Now };
context.SAMPLEs.Add(data);
context.SaveChanges();
}
// Devart.Data.Oracle v10.0
// value stored without HasPrecision(6) -> 2022-10-05 12:27:52.000000
// value stored with HasPrecision(6) -> 2022-10-05 12:31:21.060312