public void ComparePropertySqlDefaultReversed() { //SETUP var options = GetDefaultSqlDbOptions(); DatabaseModel localDatabaseModel; using (var context = new MyEntitySqlDefaultDbContext(options)) { var dtService = context.GetDesignTimeService(); var serviceProvider = dtService.GetDesignTimeProvider(); var factory = serviceProvider.GetService <IDatabaseModelFactory>(); var connectionString = context.Database.GetDbConnection().ConnectionString; context.Database.EnsureCreated(); localDatabaseModel = factory.Create(connectionString, new string[] { }, new string[] { }); } using (var context = new MyEntityDbContext(_options)) { var handler = new Stage1Comparer(context.Model, context.GetType().Name); //ATTEMPT var hasErrors = handler.CompareModelToDatabase(localDatabaseModel); //VERIFY hasErrors.ShouldBeTrue(); var errors = CompareLog.ListAllErrors(handler.Logs).ToList(); errors.Count.ShouldEqual(2); errors[0].ShouldEqual( "DIFFERENT: MyEntity->Property 'MyInt', default value sql. Expected = <null>, found = 123"); errors[1].ShouldEqual( "DIFFERENT: MyEntity->Property 'MyInt', value generated. Expected = Never, found = OnAdd"); } }
public void ComparePropertySqlDefaultSelf() { //SETUP var options = GetDefaultSqlDbOptions(); using (var context = new MyEntitySqlDefaultDbContext(options)) { var dtService = context.GetDesignTimeService(); var serviceProvider = dtService.GetDesignTimeProvider(); var factory = serviceProvider.GetService <IDatabaseModelFactory>(); var connectionString = context.Database.GetDbConnection().ConnectionString; context.Database.EnsureCreated(); #if NETCOREAPP2_1 var localDatabaseModel = factory.Create(connectionString, new string[] { }, new string[] { }); #elif NETCOREAPP3_0 var localDatabaseModel = factory.Create(connectionString, new DatabaseModelFactoryOptions(new string[] { }, new string[] { })); #endif var handler = new Stage1Comparer(context.Model, context.GetType().Name); //ATTEMPT var hasErrors = handler.CompareModelToDatabase(localDatabaseModel); //VERIFY hasErrors.ShouldBeFalse(); } }
public void ComparePropertySqlDefaultSelf() { //SETUP var options = GetDefaultSqlDbOptions(); using (var context = new MyEntitySqlDefaultDbContext(options)) { var dtService = context.GetDesignTimeService(); var serviceProvider = dtService.GetDesignTimeProvider(); var factory = serviceProvider.GetService <IDatabaseModelFactory>(); var connectionString = context.Database.GetDbConnection().ConnectionString; context.Database.EnsureCreated(); var localDatabaseModel = factory.Create(connectionString, new string[] { }, new string[] { }); var handler = new Stage1Comparer(context.Model, context.GetType().Name); //ATTEMPT var hasErrors = handler.CompareModelToDatabase(localDatabaseModel); //VERIFY hasErrors.ShouldBeFalse(); //CompareLog.ListAllErrors(handler.Logs).Single().ShouldEqual( // "DIFFERENT: Property 'MyInt', value generated. Expected = OnAdd, found = Never"); } }