Skip to content

BulkInsertAsync on Postgre, OwnsOne entity and Enum fails #1108

@osjimenez

Description

@osjimenez

I have this scenario:

public class TimeRecord
	...

	public required TimeRecordSource Source { get; set; }
}
public class TimeRecordSource
{
	public required TimeRecordSourceType Type { get; set; }
	public string? Name { get; set; }
	public string? Id { get; set; }
}
public enum TimeRecordSourceType
{
	Unknown = 0,
	Device,
	Operator,
}

With this configuration:

public class TimeRecordConfiguration : IEntityTypeConfiguration<TimeRecord>
{
	public void Configure(EntityTypeBuilder<TimeRecord> builder)
	{
		...
		builder.OwnsOne(typeof(TimeRecordSource), nameof(TimeRecord.Source));
	}
}

When I'm trying a BulkInsertAsync, I receive this error:
Can't write CLR type Namespace.TimeRecordSourceType with handler type Int32Handler

Originally, I had this configuration:

builder.OwnsOne(typeof(TimeRecordSource), nameof(TimeRecord.Source)).Property(nameof(TimeRecordSource.Type)).HasConversion<string>().HasMaxLength(50);

But failed too with this error:
Can't write CLR type Namespace.TimeRecordSourceType with handler type String

How can I do this scenario to work?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions