1
我已经在VS2017(.net core 2.0)中开始了一个新的React + Redux项目。默认模板没有使用数据库,所以我只是手动添加了实体框架的使用。它编译良好,但是当我尝试使用命令VS2017 + ReactJS +使用实体框架抛出和移植错误
dotnet ef migrations add "Initial"
,我发现了一个错误添加迁移:
An error occurred while calling method 'BuildWebHost' on class 'Program'. Continuing without the application service provider. Error: One or more errors occurred. (Webpack dev middleware failed because of an error while loading 'aspnet-webpack'. Error was: Error: Cannot find module 'aspnet-webpack'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Users\sibvic\AppData\Local\Temp\iu25u5dg.r0n:83:19)
at __webpack_require__ (C:\Users\sibvic\AppData\Local\Temp\iu25u5dg.r0n:20:30)
at createWebpackDevServer (C:\Users\sibvic\AppData\Local\Temp\iu25u5dg.r0n:62:26)
at C:\Users\sibvic\AppData\Local\Temp\ftqvg4wq.l1l:114:19
at IncomingMessage.<anonymous> (C:\Users\sibvic\AppData\Local\Temp\ftqvg4wq.l1l:133:38)
at emitNone (events.js:86:13)
Current directory is: C:\projects\test\bin\Debug\netcoreapp2.0
)
Unable to create an object of type 'ApplicationDbContext'. Add an implementation of 'IDesignTimeDbContextFactory<ApplicationDbContext>' to the project, or see https://go.microsoft.com/fwlink/?linkid=851728 for additional patterns supported at design time.
看起来这个功能太新。没有太多的信息,我可以找到。并且不能自己弄清楚什么是错误的(至少,橡皮鸭方法也行不通)。
任何想法如何解决它?
这绝对帮了我。以下是官方文档的链接:https://docs.microsoft.com/en-us/aspnet/core/migration/1x-to-2x/index#update-main-method-in-programcs – bvpb