private async Task <EstateReportingGenericContext> GetContext(String databaseName) { EstateReportingGenericContext context = null; DbContextOptionsBuilder <EstateReportingGenericContext> builder = new DbContextOptionsBuilder <EstateReportingGenericContext>() .UseInMemoryDatabase(databaseName) .ConfigureWarnings(w => w.Ignore(InMemoryEventId.TransactionIgnoredWarning)); context = new EstateReportingSqlServerContext(builder.Options); return(context); }
private async Task RemoveEstateReadModel() { List <Guid> estateIdList = this.TestingContext.GetAllEstateIds(); foreach (Guid estateId in estateIdList) { String databaseName = $"EstateReportingReadModel{estateId}"; await Retry.For(async() => { // Build the connection string (to master) String connectionString = Setup.GetLocalConnectionString(databaseName); EstateReportingSqlServerContext context = new EstateReportingSqlServerContext(connectionString); await context.Database.EnsureDeletedAsync(CancellationToken.None); }); } }
private async Task <EstateReportingGenericContext> GetContext(String databaseName, TestDatabaseType databaseType = TestDatabaseType.InMemory) { EstateReportingGenericContext context = null; if (databaseType == TestDatabaseType.InMemory) { DbContextOptionsBuilder <EstateReportingGenericContext> builder = new DbContextOptionsBuilder <EstateReportingGenericContext>() .UseInMemoryDatabase(databaseName) .ConfigureWarnings(w => w.Ignore(InMemoryEventId.TransactionIgnoredWarning)); context = new EstateReportingSqlServerContext(builder.Options); } else { throw new NotSupportedException($"Database type [{databaseType}] not supported"); } return(context); }