Пример #1
0
            protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
            {
                if (_setInternalServiceProvider)
                {
                    optionsBuilder.UseInternalServiceProvider(_serviceProvider);
                }

                optionsBuilder.UseSqlServer("Database=Maltesers");
            }
Пример #2
0
            protected internal override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
            {
                optionsBuilder.UseInternalServiceProvider(_serviceProvider);

                // ReSharper disable once ReturnValueOfPureMethodIsNotUsed
                Products.ToList();

                base.OnConfiguring(optionsBuilder);
            }
            protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
            {
                optionsBuilder.UseInternalServiceProvider(_internalServiceProvider);

                if (_root == null)
                {
                    optionsBuilder.UseInMemoryDatabase(_databaseName);
                }
                else
                {
                    optionsBuilder.UseInMemoryDatabase(_databaseName, _root);
                }
            }
Пример #4
0
            protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
            {
                optionsBuilder.UseInternalServiceProvider(_serviceProvider);

                if (_databaseName == null)
                {
                    optionsBuilder.UseInMemoryDatabase(Guid.NewGuid().ToString());
                }
                else
                {
                    optionsBuilder.UseInMemoryDatabase(_databaseName);
                }
            }
Пример #5
0
        public void Can_register_context_and_configuration_with_DI_container_and_have_both_injected()
        {
            var optionsBuilder = new DbContextOptionsBuilder()
                                 .UseInMemoryDatabase(nameof(InjectContextAndConfigurationBlogContext));

            var serviceProvider = new ServiceCollection()
                                  .AddTransient <InjectContextAndConfigurationBlogContext>()
                                  .AddTransient <InjectContextAndConfigurationController>()
                                  .AddSingleton(p => optionsBuilder.UseInternalServiceProvider(p).Options)
                                  .AddEntityFrameworkInMemoryDatabase()
                                  .BuildServiceProvider();

            serviceProvider.GetRequiredService <InjectContextAndConfigurationController>().Test();
        }
Пример #6
0
            protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
            {
                if (_useProxies)
                {
                    optionsBuilder.UseLazyLoadingProxies();
                }

                if (_internalServiceProvider != null)
                {
                    optionsBuilder.UseInternalServiceProvider(_internalServiceProvider);
                }

                optionsBuilder.UseInMemoryDatabase(_dbName ?? nameof(NeweyContext), _dbRoot);
            }
            protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
            {
                if (_setInternalServiceProvider)
                {
                    optionsBuilder.UseInternalServiceProvider(_serviceProvider);
                }

                optionsBuilder
                .UseSqlServer("Database=Maltesers",
                              b =>
                {
                    if (_rowNumberPagingEnabled)
                    {
                        b.UseRowNumberForPaging();
                    }
                });
            }
Пример #8
0
        public void Can_inject_different_configurations_into_different_contexts()
        {
            var blogOptions = new DbContextOptionsBuilder <InjectDifferentConfigurationsBlogContext>()
                              .UseInMemoryDatabase(nameof(InjectDifferentConfigurationsBlogContext));

            var accountOptions = new DbContextOptionsBuilder <InjectDifferentConfigurationsAccountContext>()
                                 .UseInMemoryDatabase(nameof(InjectDifferentConfigurationsAccountContext));

            var serviceProvider = new ServiceCollection()
                                  .AddTransient <InjectDifferentConfigurationsBlogContext>()
                                  .AddTransient <InjectDifferentConfigurationsAccountContext>()
                                  .AddTransient <InjectDifferentConfigurationsBlogController>()
                                  .AddTransient <InjectDifferentConfigurationsAccountController>()
                                  .AddSingleton(p => blogOptions.UseInternalServiceProvider(p).Options)
                                  .AddSingleton(p => accountOptions.UseInternalServiceProvider(p).Options)
                                  .AddEntityFrameworkInMemoryDatabase()
                                  .BuildServiceProvider();

            serviceProvider.GetRequiredService <InjectDifferentConfigurationsBlogController>().Test();
            serviceProvider.GetRequiredService <InjectDifferentConfigurationsAccountController>().Test();
        }
Пример #9
0
 protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
 => optionsBuilder
 .UseInternalServiceProvider(_serviceProvider)
 .UseSqlServer(SqlServerTestStore.CreateConnectionString(_databaseName), b => b.ApplyConfiguration());
Пример #10
0
 protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
 => optionsBuilder
 .UseInternalServiceProvider(_serviceProvider)
 .UseInMemoryDatabase(nameof(CustomValueGeneratorContext));
Пример #11
0
 protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
 => optionsBuilder
 .UseInternalServiceProvider(InMemoryFixture.DefaultServiceProvider)
 .UseInMemoryDatabase("Maltesers");
Пример #12
0
 protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
 => optionsBuilder
 .UseInternalServiceProvider(_serviceProvider)
 .UseInMemoryDatabase(nameof(ChangeSdlCacheContext), _on ? _databaseRoot : null);
 protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
 => optionsBuilder
 .UseInternalServiceProvider(SqlServerFixture.DefaultServiceProvider)
 .UseSqlServer(new FakeDbConnection("A=B"));
Пример #14
0
 protected internal override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
 => optionsBuilder
 .UseInternalServiceProvider(InMemoryFixture.DefaultServiceProvider)
 .UseInMemoryDatabase(databaseName: "issue7119");
Пример #15
0
 protected internal override void OnConfiguring(DbContextOptionsBuilder options)
 => options
 .UseInternalServiceProvider(InMemoryFixture.DefaultServiceProvider)
 .UseInMemoryDatabase(nameof(NullShadowKeyContext));
 protected internal override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
 => optionsBuilder
 .UseInternalServiceProvider(InMemoryFixture.DefaultServiceProvider)
 .UseInMemoryDatabase(Guid.NewGuid().ToString());
 protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
 => optionsBuilder.UseInternalServiceProvider(
     new ServiceCollection().AddEntityFrameworkInMemoryDatabase().BuildServiceProvider());
Пример #18
0
 protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
 => optionsBuilder
 .UseInternalServiceProvider(SqlServerFixture.DefaultServiceProvider)
 .UseSqlServer("Database=Maltesers");
Пример #19
0
 protected internal override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
 => optionsBuilder
 .UseInternalServiceProvider(_serviceProvider)
 .UseInMemoryDatabase(nameof(SlowContext));
 protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
 => optionsBuilder
 .UseInternalServiceProvider(InMemoryFixture.DefaultServiceProvider)
 .UseInMemoryDatabase(nameof(FraggleContext));
Пример #21
0
 protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
 => optionsBuilder
 .UseInternalServiceProvider(_serviceProvider)
 .UseSqlServer(SqlServerNorthwindTestStoreFactory.NorthwindConnectionString, b => b.ApplyConfiguration());
Пример #22
0
 protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
 => optionsBuilder
 .UseInternalServiceProvider(_serviceProvider)
 .UseInMemoryDatabase(nameof(ExplicitServicesImplicitConfigBlogContext));