EFCore.BulkExtensions icon indicating copy to clipboard operation
EFCore.BulkExtensions copied to clipboard

Upsert ignores custom conversions

Open yury-sch opened this issue 3 years ago • 1 comments

Does EFCore.BulkExntensions ignore custom conversions? I receive the exception while try to use BulkInsertOrUpdateAsync with PostgreSQL:

System.InvalidCastException: Can't write CLR type NodaTime.TimeZones.CachedDateTimeZone with handler type TextHandler

Conversion:

builder.Property(p => p.StartedAtZone).IsRequired()
    .HasConversion(zone => zone.Id, id => DateTimeZoneProviders.Tzdb.GetZoneOrNull(id)).HasMaxLength(100);

The model contains next properties from NodaTime library:

public class AnEntity
{
    ...
    public LocalDateTime StartedAt { get; set; }
    public DateTimeZone StartedAtZone { get; set; }
    ...
}

EFCore.BulkExtensions 6.2.0 Npgsql.EntityFrameworkCore.PostgreSQL.NodaTime 6.0.1

yury-sch avatar Dec 17 '21 18:12 yury-sch

Didn't have experience with NodaTime.

borisdj avatar Dec 18 '21 16:12 borisdj