public void ExtraIndexConstaint() { //SETUP var firstStageLogs = JsonConvert.DeserializeObject <List <CompareLog> >( TestData.GetFileContent("DbContextCompareLog01*.json")); var options = this.CreateUniqueClassOptions <MyEntityDbContext>( builder => builder.ReplaceService <IModelCacheKeyFactory, MyEntityModelCacheKeyFactory>()); using (var context = new MyEntityDbContext(options, MyEntityDbContext.Configs.HasIndex)) { var dtService = context.GetDesignTimeService(); var serviceProvider = dtService.GetDesignTimeProvider(); var factory = serviceProvider.GetService <IDatabaseModelFactory>(); var connectionString = context.Database.GetDbConnection().ConnectionString; context.Database.EnsureClean(); var databaseModel = factory.Create(connectionString, new DatabaseModelFactoryOptions(new string[] { }, new string[] { })); var handler = new Stage2Comparer(databaseModel); //ATTEMPT var hasErrors = handler.CompareLogsToDatabase(firstStageLogs); //VERIFY hasErrors.ShouldBeTrue(); CompareLog.ListAllErrors(handler.Logs).Single().ShouldEqual( "EXTRA IN DATABASE: Index 'MyEntites', index constraint name. Found = IX_MyEntites_MyInt"); } }
public void TestSchemaDefaultNameSqlite(MyEntityDbContext.Configs config) { //SETUP var options = SqliteInMemory.CreateOptions <MyEntityDbContext>( builder => builder.ReplaceService <IModelCacheKeyFactory, MyEntityModelCacheKeyFactory>()); using var context = new MyEntityDbContext(options, config); context.Database.EnsureCreated(); var dtService = context.GetDesignTimeService(); var serviceProvider = dtService.GetDesignTimeProvider(); var factory = serviceProvider.GetService <IDatabaseModelFactory>(); //ATTEMPT var database = factory.Create(context.Database.GetConnectionString(), new DatabaseModelFactoryOptions(new string[] { }, new string[] { })); //VERIFY database.DefaultSchema.ShouldEqual(null); }