Nat*_*yen 3 c# sql-server entity-framework entity-framework-core asp.net-core-mvc
我只是尝试使用包控制台管理器中的命令来支架 DbContext。我遵循本教程的数据库优先方法,但我总是收到“构建失败”错误消息。
https://www.entityframeworktutorial.net/efcore/create-model-for-existing-database-in-ef-core.aspx
下面是我使用的命令:
Scaffold-DbContext "Server=den1.mssql8.gear.host;Database=testdb;User Id=testdb;Password=actualPassword" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models
Run Code Online (Sandbox Code Playgroud)
与本教程不同,我尝试使用远程 SQL Server(遗憾的是,所有在线教程都使用本地 SQL Server,就好像它是世界上唯一一种数据库)我已确保已安装 SQL Server 的 EntityFramework Provider,以及使用 Nuget 的工具。
我已经挖掘了几个小时但找不到答案,所以任何形式的帮助将非常感激。
小智 5
经过这么多小时无果而终的搜索后,这对我有用
Scaffold-DbContext "Server=serverIpAddress;Database=testdb;User Id=testdb;Password=actualPassword" Microsoft.EntityFrameworkCore.SqlServer -OutputDir 模型尝试一下。