问题
I want to create a migration for a second and subsequent databases that's in a class library different from the project that uses it. There is a wrinkle. I will never know the connection string until a user logs in and I can get it from a catalog database (saas).
For the catalog database I used the solution from this site. That was fine - This database has its connection string in appsettings.json and can uses dependency injection.
The client databases are all going to be identical using the same migration. My problem is, I dont know how to create this initial migration from the Package Manager Console..
I did try to run this:
dotnet ef migrations add INITIAL --context APIcontext -s ../Jobsledger.API
and its given me the following error:
No database provider has been configured for this DbContext.
Which I expected.
Given that CodingBlast solution (above) to running migrations in a different class library requires a connection which I don't have and requires the database connection to be registered at startup...
..and given that this migration is to be used by every user database to be created how do I create it and of course use it?
来源:https://stackoverflow.com/questions/55980487/ef-core-creating-a-migration-for-a-database-without-a-connection-string-and-in