You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When this is set up, insert a single item with just whatever date value.
Then, update the value with the current timestamp value from the database (instead of C#) as follows:
awaitdbContext.Table.ExecuteUpdateAsync(x =>x.SetProperty(x =>x.Date, x =>DateTimeOffset.Now));
The issue
It correctly assumes it needs to take UTC_TIMESTAMP.
However, it doesn't take the precision into account, which is configured as 6.
So the actual query translates to something like this:
UPDATE`t`AS`t`SET`t`.`Date`= UTC_TIMESTAMP()
It's crucial in my setup that I update the row with the current timestamp from a single source with this precision, as my application may run on multiple instances that may run with a slightly desynced clock.
I cannot use any configuration that always updates the column on save, as I only need to update this column sometimes when changing other columns.
If there's any other setup that will already work for my case, I'm all ears as well.
Right now I'm resorting to ExecuteSqlInterpolatedAsync, which works, but is far from ideal.
Further technical details
MySQL version: 11.3.2-MariaDB-1:11.3.2+maria~ubu2204
Operating system: Windows 10 / Docker via WSL2
Pomelo.EntityFrameworkCore.MySql version: 8.0.2
Microsoft.AspNetCore.App version: 8
The text was updated successfully, but these errors were encountered:
Steps to reproduce
Have a simple database table with a datetime(6) column
with an associated model
and configured in the context as
When this is set up, insert a single item with just whatever date value.
Then, update the value with the current timestamp value from the database (instead of C#) as follows:
The issue
It correctly assumes it needs to take
UTC_TIMESTAMP
.However, it doesn't take the precision into account, which is configured as 6.
So the actual query translates to something like this:
It's crucial in my setup that I update the row with the current timestamp from a single source with this precision, as my application may run on multiple instances that may run with a slightly desynced clock.
I cannot use any configuration that always updates the column on save, as I only need to update this column sometimes when changing other columns.
If there's any other setup that will already work for my case, I'm all ears as well.
Right now I'm resorting to
ExecuteSqlInterpolatedAsync
, which works, but is far from ideal.Further technical details
MySQL version: 11.3.2-MariaDB-1:11.3.2+maria~ubu2204
Operating system: Windows 10 / Docker via WSL2
Pomelo.EntityFrameworkCore.MySql version: 8.0.2
Microsoft.AspNetCore.App version: 8
The text was updated successfully, but these errors were encountered: