JonPSmith / EfCore.SchemaCompare

Library to compare EF Core's Model of the database against a database's schema.
https://www.thereformedprogrammer.net/how-to-update-a-databases-schema-without-using-ef-cores-migrate-feature/
MIT License
106 stars 15 forks source link

Errors Don't Include Schema Name #6

Closed AceCoderLaura closed 3 years ago

AceCoderLaura commented 3 years ago

The errors returned from CompareEfSql.GetAllErrors don't include which schema a table is from. If a table with the same name is in a different schema the error becomes ambiguous.

JonPSmith commented 3 years ago

Hi @AceCoderLaura,

SchemaCompare will only add the schema onto the table name if it is different to EF Core's default schema name (which is 'dbo'). So, if an table has a schema name that isn't the default the error will show the schema - here is a error message from this unit test

"NOT IN DATABASE: Entity 'MyEntity', table name. Expected = MySchema.MyEntities"

This only happens when SQL Tables don't match, where it matters. All the other lower level errors, like column name, indexes, property mapping etc. never define the table. That's a pity, but putting all the information in each error would make them harder to read (and its really difficult to do!).