-
Notifications
You must be signed in to change notification settings - Fork 176
Open
Description
按照官方示例编写的简单代码
internal class TestDbContext : AbstractShardingDbContext, IShardingTableDbContext
{
public IRouteTail RouteTail { get; set; }
public TestDbContext(DbContextOptions<TestDbContext> options)
: base(options)
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<TestInfo>(e =>
{
e.Property(o => o._id).HasValueGenerator(typeof(ObjectIdValueGenerator));
e.HasIndex(o => o.Key).IsUnique();
e.Property(o => o.Value).IsRequired();
e.HasIndex(o => o.ProcTime).IsDescending();
e.ToCollection(nameof(TestInfo));
});
}
}
第一行调用ShardingProvider.ShardingRuntimeContext.UseAutoTryCompensateTable(); 就报错了:
The model must be finalized and its runtime dependencies must be initialized before 'GetRelationalModel' can be used. Ensure that either 'OnModelCreating' has completed or, if using a stand-alone 'ModelBuilder', that 'IModelRuntimeInitializer.Initialize(model.FinalizeModel())' was called.
Metadata
Metadata
Assignees
Labels
No labels