![](/img/trans.png)
[英]Microsoft SQL Server INFORMATION_SCHEMA.COLUMNS CHARACTER_MAXIMUM_LENGTH is NULL
[英]EFCore Bulk Insert & SQLite In Memory: no such table: INFORMATION_SCHEMA.COLUMNS"
我將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 timer)+MoveNext()
在 Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior 行為)
在 Microsoft.Data.Sqlite.SqliteCommand.ExecuteReaderAsync(CommandBehavior 行為,CancellationToken 取消令牌)
在 Microsoft.Data.Sqlite.SqliteCommand.ExecuteDbDataReaderAsync(CommandBehavior 行為,CancellationToken 取消令牌)
在 EFCore.BulkExtensions.TableInfo.CheckHasIdentityAsync(DbContext 上下文,CancellationToken 取消令牌)
在 EFCore.BulkExtensions.SqlBulkOperation.MergeAsync[T](DbContext 上下文,IList1 entities, TableInfo tableInfo, OperationType operationType, Action
1 進度,CancellationToken 取消1 entities, TableInfo tableInfo, OperationType operationType, Action
)
在 MyCode.Repositories.UserRepository.<>c__DisplayClass5_0.<b__0>d.MoveNext() 在 C:\\projects\\MyCode\\Repositories\\UserRepository.cs:line 48
INFORMATION_SCHEMA.COLUMNS
不是我的數據模型的一部分,也不是我試圖創建或使用的東西。 我是否需要配置或調整 EF Core 或 SQLite 以使其在內存模式下運行時支持批量操作?
我嘗試打開 EF Core 日志記錄,可以看到正在處理我的 Db 模型和正在創建表,但沒有關於批量操作的輸出,所以我不確定生成的 SQL 語句正在尋找這個Information_Schema.Columns
表。
看起來這是 EFCore.BulkExtensions for 2.5.0
中的一個錯誤,它沒有完整的 SQLite 支持。 它適用於2.6.4
版: https : //github.com/borisdj/EFCore.BulkExtensions/issues/308
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.