Database Migration
We have created the business entity—the Employee
class. Now, we can proceed with the migration. Migration is a two-step process: in the first step, we create the migration files. We have seen how to create migrations from the Package Manager Console. There is also one other way to create migrations from command-line tools. To do it, first we need to edit the MVCEF.csproj
project file and add tools to the end of the file. So your project file's ending should look like this:
... <ItemGroup> <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0-preview2-final" /> <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0-preview2-final" /> </ItemGroup> </Project>
Next, we will execute the command-line tools. This can be done by executing the following command from the Command Prompt from the context of the project:
dotnet ef migrations add InitialMigration...