linq2db.EntityFrameworkCore
linq2db.EntityFrameworkCore copied to clipboard
BulkCopy throws an Exception with ComplexProperty (Complex Type)
Following configuration throws an
Data.SqlClient.SqlException : Cannot insert the value NULL into column 'ColumnPropA', table 'IssuesEFCore.dbo.IssueXXXEntities'; column does not allow nulls. INSERT fails.
My Configuration:
public readonly record struct MyComplexType(string PropA) { }
public sealed class IssueXXXEntity
{
public required int Id { get; set; }
public required string Name { get; set; }
public MyComplexType MyComplexType { get; set; } = new MyComplexType("CT-1");
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<IssueXXXEntity>(b =>
{
b.HasKey(x => new { x.Id });
b.ComplexProperty(
cp => cp.MyComplexType,
cp =>
{
cp.Property(p => p.PropA).HasColumnName("ColumnPropA");
}
);
});
}
You can find a working repro here. Please run test with name Issue387Test
As a small reminder I changed the connection string for the IssueContext
to a different SQL Server instance.