Skip to content

使用mongodb的ef驱动 报错 #269

@x0gundam1133

Description

@x0gundam1133

按照官方示例编写的简单代码
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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions