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
- sudo wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb
- sudo dpkg -i packages-microsoft-prod.deb
- sudo apt-get install apt-transport-https
- sudo apt-get update
- 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
posted on 2019-09-09 17:15 developer1980 阅读(85) 评论(0) 收藏 举报
浙公网安备 33010602011771号