我一直在遵循以下Asp. net教程。Net核心:
https://docs.efproject.net/en/latest/platforms/aspnetcore/new-db.html我已经添加了工具:(Microsoft.EntityFrameworkCore。Tools -Pre),并像往常一样将迁移添加到任何其他Asp。. Net MVC项目,但当运行命令:"add-migration test"时,我得到以下错误:
PM> add-migration test
add-migration : COM object that has been separated from its underlying RCW cannot be used.
At line:1 char:1
+ add-migration test
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [Add-Migration], InvalidComObjectException
+ FullyQualifiedErrorId : System.Runtime.InteropServices.InvalidComObjectException,Add-Migration
PM>
我已经尝试重新安装VS2015和重新安装update3和ASP。Net Core插件,但没有效果
当我从Visual Studio中的包管理器控制台运行cmdlet时,我遇到了同样的问题。我尝试从现有的数据库中构建模型,如https://docs.efproject.net/en/latest/platforms/aspnetcore/existing-db.html所述。这是我的解决方案(感谢@Krazibit312):
- 打开命令提示符 导航到项目目录
- ,跑:
dotnet ef dbcontext scaffold "Server=(localdb)mssqllocaldb;Database=Blogging;Trusted_Connection=True;"Microsoft.EntityFrameworkCore.SqlServer - 0 Models
我想你只需要调整你的论点,它应该工作。
有关dotnet ef命令的详细信息请参见:https://learn.microsoft.com/en-us/ef/core/miscellaneous/cli/dotnet