無效的JSON文件project.json

asp.net asp.net-core entity-framework-core

我是實體框架核心的新手,我想在asp.net核心中使用實體框架核心。但是當我添加遷移firstMigration時,它總是顯示以下錯誤:

D:\ OwnLearnings \ EFCore \ AspNetCore_EFCore_001 \ src \ AspNetCore_EFCore_001 \ project.json中的無效JSON文件

Project.json:

 {
   "dependencies": {
   "Microsoft.ApplicationInsights.AspNetCore": "1.0.0",
   "Microsoft.AspNetCore.Diagnostics": "1.0.0",
   "Microsoft.AspNetCore.Mvc": "1.0.1",
   "Microsoft.AspNetCore.Razor.Tools": {
     "version": "1.0.0-preview2-final",
     "type": "build"
   },
   "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.SqlServer": "1.0.0",
   "Microsoft.EntityFrameworkCore.Tools": {
     "version": "1.0.0-preview2-final",
     "type": "build"
    },


    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
    "Microsoft.NETCore.App": {
      "version": "1.0.1",
      "type": "platform"
    },
     "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0"
    },

  "tools": {
    "BundlerMinifier.Core": "2.0.238",
    "Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
    "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final"
  },

 "frameworks": {
"netcoreapp1.0": {
  "imports": [
    "dotnet5.6",
    "portable-net45+win8"
  ]
}
},

 "buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},

 "runtimeOptions": {
"configProperties": {
  "System.GC.Server": true
}
    },

 "publishOptions": {
"include": [
  "wwwroot",
  "**/*.cshtml",
  "appsettings.json",
  "web.config"
]
    },

 "scripts": {
"prepublish": [ "bower install", "dotnet bundle" ],
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
   }

我無法找到錯誤。我第一次在實體框架中遇到這種類型的問題。提前致謝。

熱門答案

您是否缺少對依賴項中的Entity框架包的引用:

"Microsoft.EntityFrameworkCore": "1.0.0"

您還需要EF Core的導入來執行遷移和更新(命令行)。這需要在工具seciton中(工具引用也需要在你所說的依賴項中,不要刪除它)

"dependencies": {
...   
},
"tools": {
    ..,
    "Microsoft.EntityFrameworkCore.Tools": {
      "version": "1.0.0-preview2-final",
      "Imports": [
        "portable-net45+win8+dnxcore50",
        "portable-net45+win8"
      ]
    }
}...


Related

許可下: CC-BY-SA with attribution
不隸屬於 Stack Overflow
許可下: CC-BY-SA with attribution
不隸屬於 Stack Overflow