Closed guardrex closed 4 months ago
There's some info here on the subject ...
https://learn.microsoft.com/en-us/ef/efcore-and-ef6/porting/#determine-your-ef-core-flavor
Migrations in EF Core are not compatible with EF6 Code First migrations due to significant improvements to how migrations are handled.
...
This is often referred to as "code first," but the name isn't entirely accurate because one approach is to start with an existing database, generate your entities, and then maintain with code moving forward.
...
Many blog posts and articles mistakenly state this means EF Core only supports "code first." EF Core supports all three application models described in the previous section.
... that explains why they seem to disfavor it today, broadly used anyway.
It looks like the tutorials are accurate in their use of the term here, but it's also true that EF Core docs don't make much use of the term. For the Blazor tutorial, I don't plan on getting into the weeds with it. EF Core migration "flavors" š ... I'd like to order the banana-flavored š EF Core port! š
@guardrex, really good point! I will update. Thanks!!!
@guardrex, it looks like to differentiate the options for EF Core, that both "Code first" and "Code as source of truth" are used.
Per the table and the links at bottom for more info on the code first route: https://learn.microsoft.com/en-us/ef/efcore-and-ef6/porting/#determine-your-ef-core-flavor
I understand the goal of not wanting to confuse folks into thinking code first is the only option now that makes sense of course. What is the way to refer to code first if you really mean the code is the source of truth generating the rest? "Code based" is also still used I see.
What did you decide to use? Perhaps we very briefly point out there are three approaches, and we are using "Code as the source of truth approach" for this tutorial?
I avoided the problem by avoiding the language. I just remark on what the developer is doing without labeling it "Code First" anywhere in the tutorial.
Oooops! I lied! šš I was just reviewing articles of the tutorial, and I did leave one mention of it ....
Create the initial database schema using EF Core's migration feature
The migrations feature in EF Core:
- Creates the initial database schema.
- Incrementally updates the database schema to keep it in sync with the app's data model. Existing data in the database is preserved.
EF Core adopts the code-first approach for database design and maintenance:
- Entity classes are created and updated first in the app.
- The database is created and updated from the app's entity classes.
This is the reverse procedure of database-first approaches, where the database is designed, built, and updated first. Adopting EF Core's code-first approach speeds up the process of app development because most of the difficult and time-consuming database creation and management is handled transparently by the EF Core tooling, so you can focus on app development.
... but that's it tho. I don't refer to "code first"/"code-first" anyplace else in the tutorial.
Description
Wade, I noticed something else that's worth a mention ...
I went into the EF Core docs while working on the upcoming Blazor tutorial to look at a few things, and it looks like the EF folks (and doc cats) dropped "Code First"/"code-first" language when they moved from EF6 to EF Core. It's also possible that they used that language with EF Core in the past and dropped it at some point. Anyway, I don't see them using that language in EF Core docs today. However, the tutorials here contain quite a bit of "code first" language.
I'm going to avoid it for the Blazor tutorial. If you plan to keep it, please close this, as it's just a passing notion for consideration.
Page URL
https://learn.microsoft.com/en-us/aspnet/core/tutorials/razor-pages/new-field?view=aspnetcore-8.0&tabs=visual-studio
Content source URL
https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/tutorials/razor-pages/new-field.md
Document ID
24699fe5-9744-1796-0798-f7b211ec0f2f
Article author
@wadepickett
Associated WorkItem - 270946