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