我正在尝试为我正在构建的.Net Web应用程序设置应用程序基本路径.我一直在配置构建器上遇到错误.这是我得到的错误.
DNX,Version=v4.5.1 error CS1061: 'ConfigurationBuilder' does not contain a definition for 'SetBasePath' and no extension method 'SetBasePath' accepting a first argument of type 'ConfigurationBuilder' could be found (are you missing a using directive or an assembly reference?)
我假设我会得到同样的错误我.AddJsonFile()
和.AddEnvironmentVariables()
.我做错什么了吗?我没有为project.json添加正确的依赖项吗?我附上了我的startup.cs和我的project.json.
project.json
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"tooling": {
"defaultNamespace": "TripPlanner"
},
"dependencies": {
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final",
"Microsoft.Framework.Configuration": "1.0.0-beta8",
"Microsoft.Framework.DependencyInjection": "1.0.0-beta8"
//"Microsoft.Extensions.PlatformAbstractions": "1.0.0-beta8"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel"
},
"frameworks": …
Run Code Online (Sandbox Code Playgroud) 我有 ASP.NET Core 1.1 项目,我正在尝试将其转换为 v2.1。我找到了IDesignTimeDbContextFactory
实现,但我不明白我应该在哪里创建这个工厂的实例以及如何将它用于迁移正常工作。现在在创建/删除迁移之前,我必须清理并重建解决方案,因为如果没有,我会收到以下消息:Unable to create an object of type 'MyDbContext'. Add an implementation of 'IDesignTimeDbContextFactory<MyDbContext>' to the project, or see https://go.microsoft.com/fwlink/?linkid=851728 for additional patterns supported at design time
。所有上下文数据都在单独的项目中。如何使用IDesignTimeDbContextFactory
实现或我做错了什么?