小编Asa*_*ase的帖子

基于ASP.NET Core中的现有数据库创建实体框架模型

我正在尝试基于ASP.NET Core中的现有数据库创建实体框架模型.我不能让Scaffold-DbContext工作!我搜索了Stackoverflow和其他网站,看看我的ASP.NET核心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() 
Run Code Online (Sandbox Code Playgroud)

抱歉,我没有找到在英语包管理器控制台中显示错误的方法.它与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", …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc entity-framework scaffolding asp.net-core

5
推荐指数
1
解决办法
2167
查看次数