AutoFac环境中的Entity Framework Core中的DbContext实例范围

时间:2019-04-02 18:49:17

标签: c# asp.net-core entity-framework-core autofac

在这里我需要一些建议来选择哪个实例范围适合用于DbContextInstancePerLifeTime还是InstancePerRequest

[EDIT]只读数据库访问(不允许SaveChanges()SaveChangesAsync

builder.RegisterType<SchoolDataDbContext>()
    .As<ISchoolDataDbContext>()
    .WithParameter(GetDbConnectionString())
    .InstancePerLifetimeScope();

0 个答案:

没有答案