dotnetcore / dotnetcore/sharding-core

使用mongodb的ef驱动 报错

Open
#269 9 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
1.3k
Forks
183
Avg merge
7h 43m
Merged PRs (30d)
1

Description



按照官方示例编写的简单代码
internal class TestDbContext : AbstractShardingDbContext, IShardingTableDbContext
{
public IRouteTail RouteTail { get; set; }

public TestDbContext(DbContextOptions options)
: base(options)
{
}

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity(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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.