public void ModixContext_Always_ModelMatchesMigrationsSnapshot() { var optionsBuilder = new DbContextOptionsBuilder <ModixContext>() .UseNpgsql("Bogus connection string: we don't actually need to connect to the DB, just build ourselves a model."); var context = new ModixContext(optionsBuilder.Options); var migrationsAssembly = context.GetService <IMigrationsAssembly>(); var dependencies = context.GetService <ProviderConventionSetBuilderDependencies>(); var relationalDependencies = context.GetService <RelationalConventionSetBuilderDependencies>(); var modelDiffer = context.GetService <IMigrationsModelDiffer>(); var hasDifferences = false; if (migrationsAssembly.ModelSnapshot != null) { var typeMappingConvention = new TypeMappingConvention(dependencies); typeMappingConvention.ProcessModelFinalizing(((IConventionModel)migrationsAssembly.ModelSnapshot.Model).Builder, null !); var relationalModelConvention = new RelationalModelConvention(dependencies, relationalDependencies); var sourceModel = relationalModelConvention.ProcessModelFinalized(migrationsAssembly.ModelSnapshot.Model); hasDifferences = modelDiffer.HasDifferences( ((IMutableModel)sourceModel).FinalizeModel().GetRelationalModel(), context.Model.GetRelationalModel()); } hasDifferences.ShouldBeFalse(); }
public void ModixContext_Always_ModelMatchesMigrationsSnapshot() { var optionsBuilder = new DbContextOptionsBuilder <ModixContext>() .UseNpgsql("Bogus connection string: we don't actually need to connect to the DB, just build ourselves a model."); var context = new ModixContext(optionsBuilder.Options); var differences = context.GetService <IMigrationsModelDiffer>().GetDifferences( context.GetService <IMigrationsAssembly>().ModelSnapshot.Model, context.Model); differences.ShouldBeEmpty(); }