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
Your base framework: .Net Framework or .Net Core: .NET 6.0.101
Steps needed to reproduce the problem: using EF Core with postgres SQL, Npgsql.EntityFrameworkCore.PostgreSQL 6.0.2 (last version)
Exception message and stack trace if available.
Stack Trace:
info: Microsoft.EntityFrameworkCore.Database.Command[20101]
Executed DbCommand (81ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT a."Id", a."CreationTime", a."CreatorUserId", a."DeleterUserId", a."DeletionTime", a."DisplayName", a."IsDeleted", a."LastModificationTime", a."LastModifierUserId", a."Name"
FROM "AbpEditions" AS a
WHERE a."Name" = 'Standard'
LIMIT 1
fail: Microsoft.EntityFrameworkCore.Database.Command[20102]
Failed executing DbCommand (8ms) [Parameters=[@p0='?' (DbType = DateTime), @p1='?' (DbType = Int64), @p2='?' (DbType = Int64), @p3='?' (DbType = DateTime), @p4='?', @p5='?' (DbType = Boolean), @p6='?' (DbType = DateTime), @p7='?' (DbType = Int64), @p8='?'], CommandType='Text', CommandTimeout='30']
INSERT INTO "AbpEditions" ("CreationTime", "CreatorUserId", "DeleterUserId", "DeletionTime", "DisplayName", "IsDeleted", "LastModificationTime", "LastModifierUserId", "Name")
VALUES (@p0, @p1, @p2, @p3, @p4, @p5, @p6, @p7, @p8)
RETURNING "Id";
fail: Microsoft.EntityFrameworkCore.Update[10000]
An exception occurred in the database while saving changes for context type 'Sparklight.Flux.EntityFrameworkCore.FluxDbContext'.
Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while saving the entity changes. See the inner exception for details.
---> System.InvalidCastException: Cannot write DateTime with Kind=Local to PostgreSQL type 'timestamp with time zone', only UTC is supported. Note that it's not possible to mix DateTimes with different Kinds in an array/range. See the Npgsql.EnableLegacyTimestampBehavior AppContext switch to enable legacy behavior.
at Npgsql.Internal.TypeHandlers.DateTimeHandlers.TimestampTzHandler.ValidateAndGetLength(DateTime value, NpgsqlParameter parameter)
at Npgsql.Internal.TypeHandlers.DateTimeHandlers.TimestampTzHandler.ValidateObjectAndGetLength(Object value, NpgsqlLengthCache& lengthCache, NpgsqlParameter parameter)
I can fix the problem for now by following this stackoverflow
Stack Trace:
I can fix the problem for now by following this stackoverflow
Add into the Startup.cs -> Configure:
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
The text was updated successfully, but these errors were encountered: