Coldairarrow/Colder.Admin.AntdVue

多数据库操作下EFCore.Sharding报错

Closed this issue · 0 comments

在添加了一个库后使用新增的ItestRepository,
public interface ItestRepository : IRepository { }
startup新增注册代码:
config.UseDatabase<ItestRepository>(Configuration.GetConnectionString("XBRLDb"), Configuration["DatabaseType"].ToEnum<DatabaseType>());
运行程序,操作一个数据修改保存后,就会在EFCore.Sharding.DistributedTransaction这里
public async Task BeginTransactionAsync(IsolationLevel isolationLevel) { OpenTransaction = true; _isolationLevel = isolationLevel; foreach (var aRepository in _repositories) { await (aRepository as IInternalTransaction).BeginTransactionAsync(isolationLevel); } }
循环两个Repository执行,第二次则会报错。
System.NullReferenceException:“Object reference not set to an instance of an object.” (... as EFCore.Sharding.IInternalTransaction) 返回 null。