nbarbettini / little-aspnetcore-todo

Example project from The Little ASP.NET Core Book
http://littleasp.net/book
221 stars 93 forks source link

Page 53: Migration command AddItems no longer built-in in .NET Core 3 SDK #22

Open Caedendi opened 4 years ago

Caedendi commented 4 years ago

I'm on page 53, which tells the reader to run the console command dotnet ef migrations add AddItems

This ends up in an error because dotnet-ef is no longer included in the .NET Core 3 SDK and requires an explicit install before it can be used: dotnet tool install --global dotnet-ef

The error was easy to solve and i found the answer here.

Still, this should be updated and im posting this issue for anyone who runs into this in the future.

LeiYangGH commented 3 years ago

I wonder why the author uses dotnet ef ... Microsoft documents often use add-migration AddItems Does any one know their results' differences?

nbarbettini commented 3 years ago

@LeiYangGH dotnet ef and Add-Migration do the same thing. The first is a global tool that can be installed on any operating system and run from the terminal. The second is a tool specific to a feature in Visual Studio on Windows called Package Manager Console. You can use either approach and the result will be the same.

The official EF Core docs let you switch between the styles. For example, https://docs.microsoft.com/en-us/ef/core/managing-schemas/migrations/?tabs=dotnet-core-cli#create-your-first-migration

LeiYangGH commented 3 years ago

@LeiYangGH dotnet ef and Add-Migration do the same thing. The first is a global tool that can be installed on any operating system and run from the terminal. The second is a tool specific to a feature in Visual Studio on Windows called Package Manager Console. You can use either approach and the result will be the same.

The official EF Core docs let you switch between the styles. For example, https://docs.microsoft.com/en-us/ef/core/managing-schemas/migrations/?tabs=dotnet-core-cli#create-your-first-migration

Got it, thanks!