-
ABP Framework version: v7.2.0.rc2
-
UI type: Blazor
-
DB provider: EF Core - PostgreSQL
-
Tiered (MVC) or Identity Server Separated (Angular): yes / no
-
Exception message and stack trace:
-
Steps to reproduce the issue:"
Hi,
After having done the upgrade from 5.3 to 7.2 rc, I have added a migration in the EF project and have noticed that all DateTime fields are being changed from "with time zone" to "without time zone". Is it a problem? How can I avoid it? Is there some property to set?
In CreateDbContext class, I have this option"
// https://www.npgsql.org/efcore/release-notes/6.0.html#opting-out-of-the-new-timestamp-mapping-logic
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
Here is an example:
migrationBuilder.AlterColumn(
name: "LastModificationTime",
table: "SaasTenants",
type: "timestamp without time zone",
nullable: true,
oldClrType: typeof(DateTime),
oldType: "timestamp with time zone",
oldNullable: true);
10 Answer(s)
-
0
hi
Please create a new 7.2 template project with npgsql
And global search for the
EnableLegacyTimestampBehavior
keyword. -
0
MyProjectNameEntityFrameworkCoreModule
andMyProjectNameDbContextFactory
-
0
Hi Maliming,
I have those properties, exacly like the template. Anyway, it is trying to convert the DateTime types in the DB.
-
0
hi
I think you can delete the previous migrations and re-create them.
https://www.npgsql.org/efcore/release-notes/6.0.html#opting-out-of-the-new-timestamp-mapping-logic
-
0
I did that multiple times, with the options or without the options, but it is still creating that code in the migration file.
-
0
There must have a difference between your project and the template project.
Can you check the template?
or share a simple project liming.ma@volosoft.com
-
0
Hi,
I've sent an email with projects EntityFramework, Domain, and Domain.Shared.To create a new migration, I'm using Package Manager Console, selecting EntityFramework project in the combo-box, and then using this command:
add-migration Migration_7.2.0 -context SBCDbContextIt will create the code changing DateTime fields from "date with time zone" to "date without time zone".
-
1
hi
I suddenly realized that you need to remove
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
if you need date with time zone. -
0
Ok, I'll try it.
-
0
: )