.net code使用Z.EntityFramework.Plus.BulkInsertAsync报错
using Z.EntityFramework.Plus;
private readonly TDbContext _context;
private DbSet<TEntity> _entities;
public virtual DbSet<TEntity> Entities => _entities ?? (_entities = _context.Set<TEntity>());
public EfCoreRepository(TDbContext context)
{
_context = context;
}
/// <summary>
/// 批量插入
/// </summary>
/// <param name="entities"></param>
/// <returns></returns>
public async Task BulkInsertAsync(IEnumerable<TEntity> entities)
{
await _context.BulkInsertAsync(entities);
}
DbSet也一样报错
/// <summary>
/// 批量插入
/// </summary>
/// <param name="entities"></param>
/// <returns></returns>
public async Task BulkInsertAsync(IEnumerable<TEntity> entities)
{
await Entities.BulkInsertAsync(entities);
}
System.Exception: A default DbContext context must exist, or a context factory must be provided (EntityFrameworkManager.ContextFactory). This setting is required for some additional features. Read more: http://entityframework-extensions.net/context-factory
at Z.EntityFramework.Extensions.EntityFrameworkManager.(DbContext , BulkOperation )
at . [ ](BulkOperation1 this, DbContext , IEntityType , IEnumerable
1 )
at . [ ](BulkOperation1 this, DbContext , IEntityType , IEnumerable
1 , BulkOperationActionType )
at . [ ](DbContext this, IEntityType , IEnumerable1 , Action
1 , Boolean )
at . [ ](DbContext this, IEnumerable1 , Action
1 )
at DbContextExtensions. 1. () at System.Threading.Tasks.Task.InnerInvoke() at System.Threading.Tasks.Task.<>c.<.cctor>b__274_0(Object obj) at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location where exception was thrown --- at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread) --- End of stack trace from previous location where exception was thrown --- at DbContextExtensions.BulkInsertAsync[T](DbContext this, IEnumerable
1 entities, Action1 options, CancellationToken cancellationToken) at TM.Core.Domains.EfCoreRepository
2.BulkInsertAsync(IEnumerable`1 entities) in C:\Users\86156\Desktop\tmsf\framework\src\BuildingBlocks\TM.Core\Domains\EfCoreRepository.cs:line 282
at TM.Live.Services.Product.Services.SpuService.AddAsync(OperateRequest request, Int64 storeId, String realName) in C:\Users\86156\Desktop\tmsf\modules\live\src\Services\TM.Live.Services.Product\Services\SpuService.cs:line 384}
使用的包是EFCore.BulkExtensions么?版本是多少