Exemple #1
0
            protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
            {
                if (_setInternalServiceProvider)
                {
                    optionsBuilder.UseInternalServiceProvider(_serviceProvider);
                }

                optionsBuilder.UseSqlServer("Database=Maltesers");
            }
Exemple #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);
                }
            }
Exemple #4
0
            protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
            {
                optionsBuilder.UseInternalServiceProvider(_serviceProvider);

                if (_databaseName == null)
                {
                    optionsBuilder.UseInMemoryDatabase(Guid.NewGuid().ToString());
                }
                else
                {
                    optionsBuilder.UseInMemoryDatabase(_databaseName);
                }
            }
Exemple #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();
        }
Exemple #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();
                    }
                });
            }
Exemple #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();
        }
Exemple #9
0
 protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
 => optionsBuilder
 .UseInternalServiceProvider(_serviceProvider)
 .UseSqlServer(SqlServerTestStore.CreateConnectionString(_databaseName), b => b.ApplyConfiguration());
Exemple #10
0
 protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
 => optionsBuilder
 .UseInternalServiceProvider(_serviceProvider)
 .UseInMemoryDatabase(nameof(CustomValueGeneratorContext));
Exemple #11
0
 protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
 => optionsBuilder
 .UseInternalServiceProvider(InMemoryFixture.DefaultServiceProvider)
 .UseInMemoryDatabase("Maltesers");
Exemple #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"));
Exemple #14
0
 protected internal override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
 => optionsBuilder
 .UseInternalServiceProvider(InMemoryFixture.DefaultServiceProvider)
 .UseInMemoryDatabase(databaseName: "issue7119");
Exemple #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());
Exemple #18
0
 protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
 => optionsBuilder
 .UseInternalServiceProvider(SqlServerFixture.DefaultServiceProvider)
 .UseSqlServer("Database=Maltesers");
 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));
Exemple #21
0
 protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
 => optionsBuilder
 .UseInternalServiceProvider(_serviceProvider)
 .UseSqlServer(SqlServerNorthwindTestStoreFactory.NorthwindConnectionString, b => b.ApplyConfiguration());
Exemple #22
0
 protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
 => optionsBuilder
 .UseInternalServiceProvider(_serviceProvider)
 .UseInMemoryDatabase(nameof(ExplicitServicesImplicitConfigBlogContext));