Npgsql.Bulk
Npgsql.Bulk copied to clipboard
HiLo generated values
Hi,
I have an issue with Hilo value generated property, it always set as 0.
I noticed in your source code there is an Address entity with Hilo property commented out, why? I got the same property in my entity that doesn't work. It's not a shadow property (shadow properties don't work neither), is it supported at all?
Have to say it was working with EF Core 2, but after upgrading to 3.1 - property always has default value 0.
Thanks
If the property is not a Primary key or part of a composite primary key then you must add HasAlternateKey(...)
for the target property in order to use HiLo at least since EF Core 3.
Other than that what is related to the library - if you disable change tracking in BulkUploader with second constructor parameter - then it still won't generate values. Could you please consider adding something like this
if (infos.PropertyNameToGenerators == null ||
infos.PropertyNameToGenerators.Count == 0 ||
disableEntitiesTracking)
{
if (disableEntitiesTracking && infos.PropertyNameToGenerators != null)
{
foreach (var item in entities)
{
foreach (var map in infos.PropertyToGenerators)
{
var localValue = map.Key.PropertyInfo.GetValue(item);
if (map.Key.PropertyInfo.PropertyType.IsDefaultValue(localValue))
{
map.Key.PropertyInfo.SetValue(item, map.Value.Next(null));
}
}
}
}
return;
}