dotnet / efcore

EF Core is a modern object-database mapper for .NET. It supports LINQ queries, change tracking, updates, and schema migrations.
https://docs.microsoft.com/ef/
MIT License
13.76k stars 3.18k forks source link

Open up MigrationHistoryTable's model building for provider extensibility (or rethink the design) #34991

Open roji opened 1 week ago

roji commented 1 week ago

MigrationHistoryTable constructs a mini-model in order to generate the migration command for the creation of the history table in the database (code). It removes some specific conventions in order to avoid creating other tables at that point (only the migration history table).

The problem is, providers may have their own conventions which add things to the database. For example, Npgsql has conventions which create database extensions, enums, and possibly collations - all these operations shouldn't happen at this point (where all we want is to create the history table); this is the cause of https://github.com/npgsql/efcore.pg/issues/3324. But the code that generates the model - and selectively removes the conventions - is private.

We should open this up for extensibility, or possibly rethink the design here.

/cc @AndriySvyryd

AndriySvyryd commented 6 days ago

Related to https://github.com/dotnet/efcore/issues/28340