In this post, I create the ASP.Net MVC Core 2.x app, from which we will proceed, and get Entity Framework Core installed.
First, I created a new ASP.Net MVC .Net Core C# project in Visual Studio Code (see https://docs.microsoft.com/en-us/aspnet/core/tutorials/first-mvc-app-xplat/start-mvc for more).
$mkdir myApp
$cd myApp
$dotnet new mvc
I already had the .NET Core 2.0.0 SDK, Visual Studio Code, and the VS Code C# extension on my Ubuntu 16.04 Linux system. See https://docs.microsoft.com/en-us/aspnet/core/tutorials/first-mvc-app-xplat/start-mvc for more information on these steps.
Then, I issued a dotnet run to build and execute the source code:
Per the URL provided in Visual Studio Code screen above, I browsed to http:/localhost:5000:
Next, I updated the project file in Visual Studio Code (myApp.csproj) to include the following settings to install Entity Framework Core:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.5" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="2.0.0" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.2" />
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.0" />
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />
</ItemGroup>
</Project>
Then, I ran the dotnet restore command to install the above EF package and tools:
$dotnet restore
Now we have a working ASP.Net MVC Core 2.0 app with Entity Framework Core installed.
Next, in Part IV, I look at the configuration differences, in preparation of porting my existing app to use Postgresql.
No comments:
Post a Comment