Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SharedTypeEntity don't work with bulk operations #1520

Closed
paulrostorp opened this issue Jun 24, 2024 · 1 comment
Closed

SharedTypeEntity don't work with bulk operations #1520

paulrostorp opened this issue Jun 24, 2024 · 1 comment
Labels

Comments

@paulrostorp
Copy link

paulrostorp commented Jun 24, 2024

var entityType = type is null ? null : context.Model.FindEntityType(type);
if (entityType == null)
{
type = entities.FirstOrDefault()?.GetType() ?? throw new ArgumentNullException(nameof(type));
entityType = context.Model.FindEntityType(type);
HasAbstractList = true;
}
if (entityType == null)
{
throw new InvalidOperationException($"DbContext does not contain EntitySet for Type: {type?.Name}");
}

The usage of FindEntityType breaks bulk operations on SharedTypeEntity.

Possible solutions:

  1. Allow passing a specific IEntityType via parameters or bulkconfig
  2. Allow running bulk methods on a specific DB Set instead of just the context; this aligns with official EF core behavior: https://learn.microsoft.com/en-us/ef/core/change-tracking/miscellaneous#dbcontext-versus-dbset-methods
@paulrostorp paulrostorp changed the title SharedTypeEntity don't work SharedTypeEntity don't work with bulk operations Jun 24, 2024
@borisdj
Copy link
Owner

borisdj commented Aug 15, 2024

Bulk methods has parameter Type as last argument of function.
BulkInsert<T>(this DbContext context, IEnumerable<T> entities, BulkConfig? bulkConfig = null, Action<decimal>? progress = null, Type? type = null)

@borisdj borisdj closed this as completed Aug 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants