Esempio n. 1
0
        private void CreateServiceCollection()
        {
            var services = new ServiceCollection();

            services.AddOptions();
            services.AddLogging();

            var connectionString = ConnectionUtil.GetConnectionString();

            //services.AddSingleton(new SqlServerOptions { ConnectionString = connectionString });
            services.AddDbContext <TestDbContext>(options => options.UseSqlServer(connectionString));

            _services = services;
        }
Esempio n. 2
0
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            var connectionString = ConnectionUtil.GetConnectionString();

            optionsBuilder.UseSqlServer(connectionString);
        }