public DemoDatabseUnitofwork(ILoggerFactory logger, IVPD <BSiteContext> virtualPrivateDatabase) { var optionsBuilder = new DbContextOptionsBuilder <BSiteContext>(); optionsBuilder.UseLoggerFactory(logger); optionsBuilder.UseSqlServer(Core.Infrastructure.Global.DBRWManager.GetMaster(optionsBuilder.Options.ContextType.ToString()));//默认设置为主,查询的时候会自动转到从 optionsBuilder.UseNoLockSqlGenerator(); base.DbContext = new BSiteContext(optionsBuilder.Options); virtualPrivateDatabase?.SetVPD(base.DbContext); }
public MiniProgramDatabaseUniofwork(ILoggerFactory logger, IVPD <WXContext> virtualPrivateDatabase) { var optionsBuilder = new DbContextOptionsBuilder <WXContext>(); optionsBuilder.UseLoggerFactory(logger); optionsBuilder.UseSqlServer(Core.Infrastructure.Global.DBRWManager.GetMaster(optionsBuilder.Options.ContextType.ToString()));//默认设置为主,查询的时候会自动转到从 //optionsBuilder.EnableSensitiveDataLogging(); optionsBuilder.UseNoLockSqlGenerator(); base.DbContext = new WXContext(optionsBuilder.Options); virtualPrivateDatabase?.SetVPD(base.DbContext); }