Scaffold-DbContext 命令
参数
Scaffold-DbContext [-Connection] <String> [-Provider] <String> [-OutputDirectory <String>] [-ContextClassName <String>] [-Tables <String>] [-DataAnnotations] [-Project <String>] [<CommonParameters>]
范例(注意反斜线是一个)
Scaffold-DbContext "Server=.\TestDB;Database=TestDbName;Trusted_Connection=True;MultipleActiveResultSets=true;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir DataModel1
Scaffold-DbContext "Server=.\TestDB;Database=TestDbName;User ID=sa;Password=sa;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir DataModel2
效果(转载自参考资料)
参考资料
通过现有数据库在 ASP.NET Core 上开始使用 EF Core
https://docs.microsoft.com/zh-cn/ef/core/get-started/aspnetcore/existing-db
.NET Core 之 Entity Framework Core 你如何创建 DbContext
http://www.cnblogs.com/tdws/p/5874212.html
.net core 使用 ef core
http://www.cnblogs.com/ziye/p/7562889.html
原文地址:https://www.cnblogs.com/jinzesudawei/p/8904094.html
时间: 2024-10-02 13:52:10