I have been reading through this and it shows how to use EF core for custom tables but his doesn’t help when you want to use EF Core in a custom package and have it target whatever the user has selected? i.e. I want to target SQLite and MSSQL? This does not cover that situation?
Ignore me. Leaving this here for someone else. Seems you need to use IMigrationProviderSetup and IMigrationProvider
Hey @YodasMyDad, did you get this working?
I started something similar but ran into issues when I realised that the migrations themselves are implementation specific, and haven’t picked it up yet.
How have you handled generating migrations and choosing the correct one to run?
Yep all working great.
You generate migrations for both, and then Umbraco handles which one to run based on what db is running (SQLite or SqlServer etc…) from the ‘ProviderName’ in IMerchelloMigrationProvider.
i.e.
public string ProviderName => "Microsoft.Data.Sqlite";
So I have two projects, One is SQLite and one is SQLServer, almost same code just dependent on Db type, and I run the normal EF Core ‘migrations add‘ on both, it’s just normal EF core really, only you have to implement IMerchelloMigrationProviderSetup and IMerchelloMigrationProvider (and the normal EF core IDesignTimeDbContextFactory for creating migrations)
Super, thanks @YodasMyDad!