Skip to content

调整IServiceCollection.AddOsharpDbContext<TDbContext>()的执行位置 #225

@gmf520

Description

@gmf520

您的功能请求与现有问题有关吗?请描述

EntityFrameworkCorePackBase中强行注入DefaultDbContext不合理,如果不使用DefaultDbContext的时候,会造成混乱

描述您想要的需求方案

  • 移除EntityFrameworkCorePackBase中的上下文注入

    public abstract class EntityFrameworkCorePackBase : OsharpPack
    {
        public override IServiceCollection AddServices(IServiceCollection services)
        {
            // services.AddOsharpDbContext<DefaultDbContext>();
        }
    }
    
  • 改到MigrationPackBase<TDbContext>基类中执行上下文类型的注入

    public abstract class MigrationPackBase<TDbContext> : OsharpPack
    where TDbContext : DbContext
    {
        public override IServiceCollection AddServices(IServiceCollection services)
        {
            services.AddOsharpDbContext<TDbContext>();
            return services;
        }
    }
    

Metadata

Metadata

Assignees

No one assigned

    Labels

    Breaked Changes ⚡更新有破坏性,对现有业务实现有较大影响Feature 🔨新功能,新特性Finished ✔️实现并完工

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions