【发布时间】:2017-07-11 13:12:54
【问题描述】:
我正在尝试基于 ASP.NET Core 中的现有数据库创建实体框架模型。我不能让 Scaffold-DbContext 工作!我搜索了 Stackoverflow 和其他网站,看看我的 ASP.NET Core Web 应用程序项目中的包是否不正确,但我仍然无法使其工作。在包管理器控制台中运行 Scaffold-DbContext 时出现以下错误:
PM> Scaffold-DbContext "Server=.;Database=TravelAgency;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models
System.AggregateException: Ett eller flera fel har uppst�tt. ---> System.MethodAccessException: Ett f�rs�k av metoden Microsoft.EntityFrameworkCore.Scaffolding.Configuration.Internal.ModelConfiguration.get_EntityConfigurations()
att komma �t metoden Microsoft.EntityFrameworkCore.Metadata.Internal.EntityTypeNameComparer..ctor() misslyckades. vid Microsoft.EntityFrameworkCore.Scaffolding.Configuration.Internal.ModelConfiguration.get_EntityConfigurations()
抱歉,我没有找到在包管理器控制台中用英文显示错误的方法。这是关于 System.AggregateException:发生了一个或多个错误。 我的 project.json 文件如下所示:
{
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"dependencies": {
"EntityFramework": "6.1.3",
"Microsoft.AspNetCore.Authentication.Cookies": "1.0.0",
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.0.0",
"Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.1",
"Microsoft.AspNetCore.Razor.Tools": {
"type": "build",
"version": "1.0.0-preview2-final"
},
"Microsoft.AspNetCore.Routing": "1.0.1",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
"Microsoft.AspNetCore.StaticFiles": "1.0.0",
"Microsoft.EntityFrameworkCore": "1.1.0",
"Microsoft.EntityFrameworkCore.Design": "1.0.0-preview2-final",
"Microsoft.EntityFrameworkCore.SqlServer": "1.1.0",
"Microsoft.EntityFrameworkCore.SqlServer.Design": "1.1.0",
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Configuration.UserSecrets": "1.0.0",
"Microsoft.Extensions.Logging": "1.1.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0",
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.VisualStudio.Web.CodeGenerators.Mvc": {
"type": "build",
"version": "1.0.0-preview2-final"
},
"NuGet.CommandLine": "3.5.0"
},
"frameworks": {
"net461": {}
},
"publishOptions": {
"include": [
"wwwroot",
"**/*.cshtml",
"appsettings.json",
"web.config"
]
},
"runtimeOptions": {
"configProperties": {
"System.GC.Server": true
}
},
"scripts": {
"prepublish": [ "bower install", "dotnet bundle" ],
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
},
"tools": {
"BundlerMinifier.Core": "2.0.238",
"Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",
"Microsoft.Extensions.SecretManager.Tools": "1.0.0-preview2-final",
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
"version": "1.0.0-preview2-final",
"imports": [
"portable-net45+win8"
]
}
},
"userSecretsId": "aspnet-TravelAgencyApplication-3fa3cffa-93a0-470d-b08a-145e604eb5f7"
}
提前致谢! 最好的问候,阿提拉
【问题讨论】:
标签: c# asp.net-mvc entity-framework asp.net-core scaffolding