我创建了一个ASP.NET Core 2项目,创建了一些迁移过程,并将代码推送到存储库。ASP.NET Core 2迁移不适用于具有空数据库的新机器
今天,我将代码拉到了另一台用于开发的计算机上,数据库显然不是在新机器上创建的,所以我在本地创建了一个空数据库以匹配连接字符串。
现在,试图运行代码“DOTNET EF数据库更新”我得到这个错误时:
An error occurred while calling method 'BuildWebHost' on class 'Program'. Continuing without the application service provider. Error: One or more errors occurred. (Invalid object name 'AspNetUsers'.) Unable to create an object of type 'AppDbContext'. Add an implementation of 'IDesignTimeDbContextFactory' to the project, or see https://go.microsoft.com/fwlink/?linkid=851728 for additional patterns supported at design time.
请记住,任何“DOTNET EF”命令我跑我也有同样的错误,我尝试使用“dotnet ef migrations add InitialDb”命令删除所有迁移并创建一个新的迁移,但我仍然遇到此错误。
我使用的身份在我的项目,我相信它也与此错误:(无效的对象名称AspNetUsers')
的命令运行没有机器上的任何问题,我最初开始研制应用。
我试着从PM下载更新数据库,结果相同。
预先感谢。