public OneToOneQuerySqlCeFixture() { _serviceProvider = new ServiceCollection() .AddEntityFramework() .AddSqlCe() .ServiceCollection() .AddSingleton(TestSqlCeModelSource.GetFactory(OnModelCreating)) .AddSingleton <ILoggerFactory>(new TestSqlLoggerFactory()) .BuildServiceProvider(); var database = SqlCeTestStore.CreateScratch(createDatabase: true); var optionsBuilder = new DbContextOptionsBuilder(); optionsBuilder.UseSqlCe(database.Connection.ConnectionString); _options = optionsBuilder.Options; using (var context = new DbContext(_serviceProvider, _options)) { context.Database.EnsureCreated(); AddTestData(context); } }
public TransactionSqlCeFixture() { _serviceProvider = new ServiceCollection() .AddEntityFramework() .AddSqlCe() .ServiceCollection() .AddSingleton(TestSqlCeModelSource.GetFactory(OnModelCreating)) .BuildServiceProvider(); }
protected GraphUpdatesSqlCeFixtureBase() { _serviceProvider = new ServiceCollection() .AddEntityFramework() .AddSqlCe() .ServiceCollection() .AddSingleton(TestSqlCeModelSource.GetFactory(OnModelCreating)) .BuildServiceProvider(); }
public ComplexNavigationsQuerySqlCeFixture() { _serviceProvider = new ServiceCollection() .AddEntityFramework() .AddSqlCe() .ServiceCollection() .AddSingleton(TestSqlCeModelSource.GetFactory(OnModelCreating)) .AddSingleton <ILoggerFactory>(new TestSqlLoggerFactory()) .BuildServiceProvider(); }
public NorthwindQuerySqlCeFixture() { _serviceProvider = new ServiceCollection() .AddEntityFramework() .AddSqlCe() .ServiceCollection() .AddSingleton(TestSqlCeModelSource.GetFactory(OnModelCreating)) .AddSingleton <ILoggerFactory>(_testSqlLoggerFactory) .BuildServiceProvider(); _options = BuildOptions(); }
public NullKeysSqlServerCeFixture() { _serviceProvider = new ServiceCollection() .AddEntityFramework() .AddSqlCe() .ServiceCollection() .AddSingleton(TestSqlCeModelSource.GetFactory(OnModelCreating)) .BuildServiceProvider(); var optionsBuilder = new DbContextOptionsBuilder(); optionsBuilder.UseSqlCe(SqlCeTestStore.CreateConnectionString("StringsContext")); _options = optionsBuilder.Options; EnsureCreated(); }
public BuiltInDataTypesSqlCeFixture() { _testStore = SqlCeTestStore.CreateScratch(createDatabase: true); _serviceProvider = new ServiceCollection() .AddEntityFramework() .AddSqlCe() .ServiceCollection() .AddSingleton(TestSqlCeModelSource.GetFactory(OnModelCreating)) .BuildServiceProvider(); var optionsBuilder = new DbContextOptionsBuilder(); optionsBuilder.UseSqlCe(_testStore.Connection); _options = optionsBuilder.Options; using (var context = new DbContext(_serviceProvider, _options)) { context.Database.EnsureCreated(); } }
public InheritanceSqlCeFixture() { _serviceProvider = new ServiceCollection() .AddEntityFramework() .AddSqlCe() .ServiceCollection() .AddSingleton(TestSqlCeModelSource.GetFactory(OnModelCreating)) .AddSingleton <ILoggerFactory>(new TestSqlLoggerFactory()) .BuildServiceProvider(); var testStore = SqlCeTestStore.CreateScratch(createDatabase: true); var optionsBuilder = new DbContextOptionsBuilder(); optionsBuilder .EnableSensitiveDataLogging() .UseSqlCe(testStore.Connection); _options = optionsBuilder.Options; // TODO: Do this via migrations testStore.ExecuteNonQuery(@" CREATE TABLE Country ( Id int NOT NULL PRIMARY KEY, Name nvarchar(100) NOT NULL );"); testStore.ExecuteNonQuery(@" CREATE TABLE Animal ( Species nvarchar(100) NOT NULL PRIMARY KEY, Name nvarchar(100) NOT NULL, CountryId int NOT NULL, IsFlightless bit NOT NULL, EagleId nvarchar(100), [Group] int, FoundOn tinyint, Discriminator nvarchar(255) NOT NULL );"); testStore.ExecuteNonQuery(@" ALTER TABLE [Animal] ADD CONSTRAINT[EagleId_FK] FOREIGN KEY ([EagleId]) REFERENCES[Animal]([Species]) ON DELETE NO ACTION ON UPDATE NO ACTION;"); testStore.ExecuteNonQuery(@" ALTER TABLE [Animal] ADD CONSTRAINT[CountryId_FK] FOREIGN KEY ([CountryId]) REFERENCES[Country]([Id]) ON DELETE NO ACTION ON UPDATE NO ACTION;"); testStore.ExecuteNonQuery(@" CREATE TABLE Plant( Genus int NOT NULL, Species nvarchar(100) NOT NULL PRIMARY KEY, Name nvarchar(100) NOT NULL, CountryId int NULL, HasThorns bit );"); testStore.ExecuteNonQuery(@" ALTER TABLE [Plant] ADD CONSTRAINT[PlantCountryId_FK] FOREIGN KEY ([CountryId]) REFERENCES[Country]([Id]) ON DELETE NO ACTION ON UPDATE NO ACTION;"); using (var context = CreateContext()) { SeedData(context); } }