我将EFCore BulkExtensions 2.5.0与Entity Framework Core 2.2.3和EFCore.SQLite 2.2.6一起使用。
我有这样的代码:
// Repo that throws exception on BulkInsert
public class UserRepository
{
private readonly IDbContextProvider<ReportContext> _dbContextProvider;
public async Sync(IList<User> users)
{
await _dbContextProvider.Context.BulkInserOrUpdateAsync(users);
}
}
// Poco Model
public class User
{
public string Id {get;set;}
public string Name {get; set;}
}
// Simple DbContext
public class ReportsContext : DbContext
{
public DbSet<User> Users { get; set; }
}
我的应用程序代码(使用EFCore.Sql
)可以正常运行。但是,当我的测试代码使用SQLite内存运行时,出现异常:
没有这样的表:INFORMATION_SCHEMA.COLUMNS
Microsoft.Data.Sqlite.SqliteException:SQLite错误1:'没有这样的表:INFORMATION_SCHEMA.COLUMNS'。
在Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc,sqlite3 db)在Microsoft.Data.Sqlite.SqliteCommand.PrepareAndEnumerateStatements(Stopwatch计时器)+ MoveNext()在Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior行为)在Microsoft.Data.Sqlite.SqliteCommand.ExecuteReaderAsync(CommandBehavior行为,CancellationToken cancelToken)在Microsoft.Data.Sqlite.SqliteCommand.ExecuteDbDataReaderAsync(CommandBehavior行为,CancellationToken cancelToken)在EFCore.BulkExtensions.TableInfo.CheckHasIdentityAsync(DbContext上下文,CancellationToken cancelledToken)在EFCore.BulkExtensions.SqlBulkOperation.MergeAsync [T](DbContext上下文,IList
中的[d.MoveNext()1 entities, TableInfo tableInfo, OperationType operationType, Action
1进度,CancellationToken cancelledToken)在MyCode.Repositories.UserRepository。<> c__DisplayClass5_0。C:\ projects \ MyCode \ Repositories \ UserRepository.cs:line 48 ]
INFORMATION_SCHEMA.COLUMNS
不是我的数据模型的一部分,也不是我试图创建或使用的东西。在内存模式下运行时,是否需要配置或调整EF Core或SQLite以使其支持批量操作?
我已经尝试过turning on EF Core logging,并且可以看到正在处理我的Db模型并正在创建表,但是在批量操作上没有输出,因此我不确定生成的SQL语句正在寻找此Information_Schema.Columns
表。
看来这是EFCore.BulkExtensions for 2.5.0
中的错误,该错误没有完整的SQLite支持。它适用于版本2.6.4
:https://github.com/borisdj/EFCore.BulkExtensions/issues/308