-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CheckMigrated #24866
Comments
This looks good @ajcvickers. What do you think we should do with regards to actually calling |
This could leverage the API proposed in #22105 (comment) to check for unscaffolded migrations. |
📝 Design meeting notes
|
"VerifyMigrated" ? |
One of the dilemmas of "getting started" applications and examples is that creating the database in code when the application starts is by far the easiest way to get up and running with a database, but this is considered an anti-pattern for most production applications. So, even though its a bit harder, we want people to start with something like Migrations which allows us to show best practice from the start. However, using Migrations requires running some commands at the command line.
The idea behind
EnsureMigrated
is to have a single, simple line of code that can safely be run when starting an application and which will check if Migrations have been created and applied to the database. If no migrations are found in the project, thenEnsureMigrated
will stop and indicate that the user should rundotnet ef migrations add
. For example:We can potentially also detect other conditions such as a migration exists, but
update database
has not been called. We may also want to check if thedotnet-ef
tool is installed and give instructions for that.To make this easier, we could create a new command that will add a migration and update the database in one go. For example:
The end-result is guidance towards best practice with minimal input from the user. It's also not magic--that is, the user knows that they are creating a database.
Thoughts @davidfowl @bricelam @JeremyLikness @halter73 @LadyNaggaga @glennc
The text was updated successfully, but these errors were encountered: