Loading

efcore dbfirst 通过数据库表反向生成model

创建class library并设置为启动项目
使用nuget控制台,设置当前项目为新建的class library

Install-Package Microsoft.EntityFrameworkCore.Tools
Install-package Microsoft.EntityFrameworkCore.SqlServer

Scaffold-DbContext "Server=.;Database=dbname;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models

使用dotnet cli

dotnet ef dbcontext scaffold "Server=.;Database=dbname;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -o Models

参考:
http://www.entityframeworktutorial.net/efcore/create-model-for-existing-database-in-ef-core.aspx
https://stackoverflow.com/questions/39454545/the-term-scaffold-dbcontext-is-not-recognized-as-the-name-of-a-cmdlet-functio

posted @ 2019-01-22 17:29  wswind  阅读(1889)  评论(0编辑  收藏  举报