CheckMigrated
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
Research direction
Start by reviewing the proposed EnsureMigrated behavior and the alternative dotnet ef database initialize command. Done means clearly deciding the supported migration checks and providing guidance that helps users create and update a database while following migration best practices.
Written by the indexing model from the issue text.
Description
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, then EnsureMigrated will stop and indicate that the user should run dotnet ef migrations add. For example:
A database must be created for this application. Enter the following commands to create a database using EF Core Migrations:
dotnet ef migrations add InitialMigration
dotnet ef database update
See https://aka.ms/databasemigrations for more information.
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 the dotnet-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:
A database must be created for this application. Enter the following commands to create a database using EF Core Migrations:
dotnet ef database initialize
See https://aka.ms/databasemigrations for more information.
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
- Dominant language
- C#
- Stars
- 14.8k
- Forks
- 3.4k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 134
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dotnet/efcore
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
-
customer-reported
Difficulty 5/5 Over a week Newbie friendliness 38/100
-
area-cosmos area-vector-search
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
area-cosmos
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
area-tools needs-design
Difficulty 4/5 3-5 days Newbie friendliness 25/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
:watch: Not Triaged 11.0 fundamentals/subsvc
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
dotnet/AspNetCore.Docs#37699 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
SubtitleEdit/subtitleedit#15108 · 1 comment ·
-
area/docs-content Bug pulumi/docs
Difficulty 1/5 1-3 hours Newbie friendliness 94/100
-
agentic-workflows untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 76/100