Example #1
0
        private static void DoAdd(IServiceCollection services, IConfiguration config, SqlServerServiceInfo info, Type dbContextType, ServiceLifetime contextLifetime)
        {
            var sqlServerConfig = new SqlServerProviderConnectorOptions(config);

            var factory = new SqlServerDbContextConnectorFactory(info, sqlServerConfig, dbContextType);

            services.Add(new ServiceDescriptor(dbContextType, factory.Create, contextLifetime));
        }
        private static void DoAdd(IServiceCollection services, IConfiguration config, SqlServerServiceInfo info, Type dbContextType, ServiceLifetime contextLifetime)
        {
            var sqlServerConfig = new SqlServerProviderConnectorOptions(config);

            var factory = new SqlServerDbContextConnectorFactory(info, sqlServerConfig, dbContextType);

            services.Add(new ServiceDescriptor(dbContextType, factory.Create, contextLifetime));
            var healthFactory = new SqlServerProviderConnectorFactory(info, sqlServerConfig, SqlServerTypeLocator.SqlConnection);

            services.Add(new ServiceDescriptor(typeof(IHealthContributor), ctx => new RelationalDbHealthContributor((IDbConnection)healthFactory.Create(ctx), ctx.GetService <ILogger <RelationalDbHealthContributor> >()), contextLifetime));
        }