-
-
Notifications
You must be signed in to change notification settings - Fork 620
Closed
Labels
Description
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?