EntityFramework Core Migrations | ASP.NET CORE | CLI Migrations | Package Manager Console Migratio
Summary
TLDRThis tutorial video guides viewers through the process of performing migrations in Entity Framework using .NET. It starts by instructing how to download and install the .NET EF global tool, version 3.1.3, via CLI. The host then demonstrates opening the command prompt, utilizing the 'dotnet ef' command to add and manage migrations, and ensuring the syntax is correct. The video covers creating a migration with a specified name and updating the database with the 'update-database' command. It also addresses how to rectify common errors like spelling mistakes and concludes with verifying the migration's success in SQL Server. Additionally, the video briefly touches on using the Package Manager Console for migrations, providing an alternative to CLI.
Takeaways
- 😀 The video is a tutorial on how to perform migration in Entity Framework using .NET.
- 🔧 First step is to download the .NET EF tool globally using the CLI command 'dotnet tool install --global dotnet-ef --version 3.1.3'.
- 📁 To access the command prompt, navigate to the project folder, type 'CMD' in the address bar, and press enter.
- 🔎 Use 'dotnet ef --help' to get a list of available commands and options for Entity Framework migrations.
- 📝 The 'dotnet ef migrations' command is used to manage database context and migrations.
- 🚀 To add a migration, use the syntax 'dotnet ef migrations add [MigrationName]' where [MigrationName] is the name of the migration.
- 🛠 After adding a migration, use 'dotnet ef database update' to apply the changes to the database.
- 🔄 The video demonstrates how to check for unrecognized commands or arguments and correct any spelling mistakes.
- 📚 It shows how to use the 'dotnet ef database update' command to create a physical table in a local SQL Server database.
- 🔍 The tutorial also covers how to check the database using SQL Server Management Studio to ensure the migration was successful.
- 📋 Lastly, the video explains how to use the Package Manager Console for migrations with commands like 'Add-Migration' and 'Update-Database'.
Q & A
What is the main topic of the video?
-The main topic of the video is demonstrating how to perform migration in Entity Framework using .NET Core CLI.
How can one download .NET EF globally?
-To download .NET EF globally, use the command 'dotnet tool install --global dotnet-ef --version 3.1.3' in the CLI.
What is the purpose of opening the command prompt from the project folder?
-Opening the command prompt from the project folder allows you to execute .NET EF commands related to that specific project.
How can viewers access the help section for .NET EF commands?
-Viewers can access the help section for .NET EF commands by typing 'dotnet ef --help' in the command prompt.
What command is used to add a new migration?
-The command used to add a new migration is 'dotnet ef migrations add' followed by the name of the migration.
What is the correct syntax for adding a migration in a .NET project?
-The correct syntax is 'dotnet ef migrations add <MigrationName>' where <MigrationName> is the name you assign to the migration.
What command is used to update the database after adding a migration?
-The command used to update the database is 'dotnet ef database update'.
How can one check for a spelling mistake in the commands?
-One can check for spelling mistakes by referring back to the help section or by carefully reviewing the command syntax.
What does the video guide on checking the database after migration?
-The video guides on checking the database by opening SQL Server Object Explorer and looking for the migration under the specified holder name.
What are the two methods demonstrated in the video for using migration in Entity Framework?
-The two methods demonstrated are using .NET Core CLI and using the Package Manager Console.
How can one get help about Entity Framework in the Package Manager Console?
-One can get help about Entity Framework by typing 'get-help about entity framework' in the Package Manager Console.
Outlines
🚀 Introduction to Entity Framework Migration with CLI
This paragraph introduces the topic of Entity Framework migration using the Command Line Interface (CLI). The speaker begins by instructing viewers to download the .NET EF tool globally using CLI. They provide a step-by-step guide on how to access the command prompt from the project folder by typing 'CMD' in the address bar and pressing enter. The speaker then explains how to use the 'dotnet ef' command to check for help and the correct syntax for adding migrations. They emphasize the importance of checking the syntax for the 'add-migration' command and provide guidance on using the 'dotnet ef migrations add' command with the correct options and arguments, including the migration name. The paragraph concludes with a brief mention of the 'update-database' command, which is used to manage the database after migrations are added.
🔍 Database Migration Verification and Using Package Manager Console
The second paragraph covers the process of verifying database migration and introduces an alternative method for performing migrations using the Package Manager Console. The speaker starts by explaining how to check for a newly created physical table in a local SQL Server database after a successful build. They guide the viewer to open SQL Server and verify the presence of the migration in the Object Explorer under the specified database. The paragraph then shifts to discuss how to perform migrations using the Package Manager Console, starting with accessing the help section to understand the available Entity Framework commands. The speaker details the process of adding a migration with a specified name and updating the database using the 'update-database' command. They conclude by highlighting the two primary methods for using migrations in Entity Framework: CLI and Package Manager Console, and thank the viewers for watching.
Mindmap
Keywords
💡ASP.NET
💡Entity Framework
💡Migration
💡CLI (Command Line Interface)
💡dotnet tool install
💡DbContext
💡add migration
💡update database
💡Package Manager Console
💡SQL Server
💡get help
Highlights
Introduction to the process of migration in Entity Framework.
Downloading .NET EF globally using CLI with the command 'dotnet tool install --global dotnet-ef --version 3.1.3'.
Accessing the command prompt by navigating to the project folder and typing 'CMD' in the address bar.
Using 'dotnet ef --help' to understand the available options and commands for Entity Framework migrations.
Explanation of 'dotnet ef options' and 'dotnet ef commands' for managing database context and migrations.
Syntax for adding a migration using 'dotnet ef migrations add <MigrationName>', emphasizing the importance of the migration name.
How to correct syntax errors in the 'add migration' command by referring to the help section.
Building the migration successfully with the correct syntax and initiating the process.
Using 'update database' command to manage the database schema after migrations.
Instructions on how to use the 'update database' command with the correct syntax.
Correcting a spelling mistake in the 'update database' command and ensuring the correct usage.
Verification of the physical table creation in SQL Server LocalDB after updating the database.
Demonstration of checking the database and migrations in SQL Server Object Explorer.
Introduction to using Package Manager Console for Entity Framework migrations.
How to get help in the Package Manager Console with 'get help' and understanding the available commands.
Using 'add-migration' and 'update-database' commands in the Package Manager Console for migrations.
Explanation of the 'up' and 'down' methods in migration classes and their role in model changes.
Applying an example of adding a column to a model and updating the database using migrations.
Conclusion summarizing the two methods of using migrations in Entity Framework: CLI and Package Manager Console.
Transcripts
hello everyone welcome on my channel
asp.net for today I am going to show you
migration in entity framework or so
first of all download dotnet EF using
CLI dotnet tool installed - - global
dotnet EF version 3.1 point 3 after
download the dotnet EF it's a global
tool to download it easily by using your
command line and after that you can open
your command prompt and how to open your
command from - just go to your project
folder there is migration tutorial and
after in the search bar or sorry in in
the address bar just type CMD and enter
you got it that screen after pressing
the enter button just taken help dotnet
EF - - help and the following command
and uses is there with the example you
can follow uses that your screen that is
not net EF options and command so dotnet
EF options is their version health but
command is their database TB context and
migrations so dotnet EF migrations and
the name migrations and add is there but
in the migration in the migration ad but
migration name is missing in the syntax
so just check the syntax of the add
migration command so just again you can
take help section again so just a type
dotnet EF in it migration that is the
direct to think you can do in it
migration is it right syntax of the
migration I think it is strong so just
you can take help if you want to take
help how to do add migration command in
dotnet so you can use dotnet EF
migration help so just write it
migrations and - - help so related to
the my
raishin you by normal CLI provide a HAMP
section and users also check uses dotnet
EF migration option and command option
is there and command is there that is
the ad so again you can write or net EF
migrations and command name that is ad -
again have ad how to do ad command in
migration that is the right name that is
the name of the migration so uses is
they are dotnet EF migration ad and the
option and argument argument and options
so argument is there the name of the
migration so just you can write the
syntax is dotnet EF migration ad and the
name of the migration is the correct
syntax to add migration in your visual
studio project in dotnet represents so
just write your that is the correct
syntax dotnet EF migrations ad and the
name of the migration that is in it so
build started build succeed so migration
is completed at my by using the
migrations add migrations command and
you have to use update database command
is also there just you have to check
database command to manage the database
and users is dotnet EF and command so
use dotnet EF and command name is
database but how to use update database
command so just again check it help
dotnet EF - - help database how to use
in the.net EF use database there is the
following thing is large where you have
to check dotnet EF - - help database you
can use update the name dotnet t of
database and option and comma
name is AB drop and database is there so
you can apply it directly dotnet EF
database and database command that is
update so use dotnet EF database and
database command name that is database
update so this is the syntax to update
your database using CLI so unrecognized
command or argument data
oops the spelling mistake is here dotnet
EF database and the name of the database
is a is missing in the spelling of
database so after update the database
you have got a physical table in your
database in your sequel's server local
DB so build started and will succeed and
finally done to and check your database
using sequel server so just open
database command and your Microsoft your
migration example database is there in
your sequel server object Explorer and
check your init migration under the
holder name migration yeah is there and
model student app settings database
migration example yeah is all things are
there and just now how to do migration
using package manager console so just
you can use gap help section by using
get help you got all these command
related to entity framework or if you
you are using get help without any thing
just got a space just like that server
help save help update help about entity
framework or so just again type it get
help
about entity framework or so you just
get information about entity framework
or commands like add migrations remove
migrations update migrations
Sacre's so add migration and the
migration name is first before any
changes in the model you got two classes
both are empty if nothing changes in the
model that is up-and-down methods are
empty in the first migration class
because here is nothing changes but if
you change anything in the model then up
section up method and the our overridden
up method and overhead and down method
is taking some code and statements you
can say just after that again at
migrations command applied you got a
simple syntax add column string email
now after that you got and you have to
apply update database command again by
using package manager console so just
done it so these this is that two way to
use migration in entity framework or the
first is CLI and the second one is
package manager console so thank you
guys for watching this video keep
watching
関連する他のビデオを見る
![](https://i.ytimg.com/vi/fl6r-9rQjns/hq720.jpg)
Entity Framework Migrations Explained
![](https://i.ytimg.com/vi/SvIBPUDgQVg/hq720.jpg?v=63bd279f)
Generate C# Model from existing Microsoft SQL Server Database
![](https://i.ytimg.com/vi/CScxy0294SE/hq720.jpg)
#2 Python Tutorial for Beginners | Python Installation | PyCharm
![](https://i.ytimg.com/vi/FRrslz_AHzE/hq720.jpg)
Getting Started with .NET Upgrade Assistant [3 of 18] Migrating from ASP.NET to ASP.NET Core
![](https://i.ytimg.com/vi/XqtEWcNNZrA/hq720.jpg)
How to connect EC2 instance over SSH using Windows and Mac? | Visual Explanations
![](https://i.ytimg.com/vi/U-VG_E4kxWI/hq720.jpg)
How to Use the WHOIS Command to Lookup Ip and Domain Name Information
5.0 / 5 (0 votes)