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

NullReferenceException on BulkInsert with Owned Entity Type on a backing field

Open IT-CASADO opened this issue 1 year ago • 1 comments

Hi,

I'm having trouble to bulk insert some entity with an owned type. The owned type is a private backing field (_fieldA) (and used by some other public setters)

I get a NullReferenceException on this line: https://github.com/borisdj/EFCore.BulkExtensions/blob/304f48643a294dd274ef256389ec800452e0e521/EFCore.BulkExtensions/TableInfo.cs#L548

I can see that navigationProperty.PropertyInfo is null, but navigationProperty.FieldInfo is not null.

You can find a working repro here: https://github.com/IT-CASADO/EfCoreBulkExtensionsBugs

You can execute the unit tests in the test project.

I'm currently using .NET 6, but I also get this on .NET 8.

IT-CASADO avatar Dec 12 '23 20:12 IT-CASADO

Not sure how to get PropertyInfo from private field. If you can maybe try try to change your entity to standard model with public Property.

borisdj avatar Jan 18 '24 09:01 borisdj