Dotnet Core Use EF.core initial project

reference websit :https://www.entityframeworktutorial.net/efcore/install-entity-framework-core.aspx

1  create .net core project

     Add new project. Add select .net core Liberay project.

2  Add  EF.core

    Via Nuget add “Microsoft.EntityFrameworkCore.SqlServer” and  Microsoft.EntityFrameworkCore.Tools

3 Generate Module Entity Class 

   In console of Nuget  .Execute    Scaffold-DbContext "Server=39.106.2.102;Database=databaseName;user=sa;pwd=****;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir ModelsWSC  -Force

   then automatic generate entities and Context class in ModelsWSC folder.

4 Use it

using (var context = new WSC_FCDBContext())
{

var std = new FcOpcConfig()
{
Channel="zdntest"
};

context.FcOpcConfig.Add(std);
context.SaveChanges();
}

 

一、 initial developer enviarement  

     install  .net core 

  1. sudo wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb  
  2. sudo dpkg -i packages-microsoft-prod.deb  
  3.   
  4. sudo apt-get install apt-transport-https  
  5. sudo apt-get update  
  6. sudo apt-get install dotnet-sdk-2.1  

   initial dotnet core project

     mkdir IndustryPlatform

     cd IndustryPlatform

     dotnet new sln

     dotnet new classlib -o DataAccessLayer

     dotnet new webapi -o WebApiLayer

     dotnet sln IndustryPlatform.sln add DataAccessLayer/DataAccessLayer.csproj 

     dotnet sln IndustryPlatform.sln add WebApiLayer/WebApiLayer.csproj 

 https://dejanstojanovic.net/aspnet/2018/september/setting-up-net-core-development-environment-on-ubuntu-linux/

 

 

 

 

      

posted on 2019-09-09 17:15  developer1980  阅读(85)  评论(0)    收藏  举报

导航