19 lines
1.2 KiB
Markdown
19 lines
1.2 KiB
Markdown
|
## Add initial migration and update the database
|
||
|
|
||
|
* Open a command prompt and navigate to the project directory. (The directory containing the *Startup.cs* file).
|
||
|
|
||
|
* Run the following commands in the command prompt:
|
||
|
|
||
|
```console
|
||
|
dotnet restore
|
||
|
dotnet ef migrations add Initial
|
||
|
dotnet ef database update
|
||
|
```
|
||
|
|
||
|
[.NET Core](http://go.microsoft.com/fwlink/?LinkID=517853) is a cross-platform implementation of .NET. Here is what these commands do:
|
||
|
|
||
|
* `dotnet restore`: Downloads the NuGet packages specified in the *.csproj* file.
|
||
|
* `dotnet ef migrations add Initial` Runs the Entity Framework .NET Core CLI migrations command and creates the initial migration. The parameter after "add" is a name that you assign to the migration. Here you're naming the migration "Initial" because it's the initial database migration. This operation creates the *Data/Migrations/\<date-time>_Initial.cs* file containing the migration commands to add the *Movie* table to the database.
|
||
|
* `dotnet ef database update` Updates the database with the migration we just created.
|
||
|
|
||
|
You'll learn about the database and connection string in the next tutorial. You'll learn about data model changes in the [Add a field](xref:tutorials/first-mvc-app/new-field) tutorial.
|