【问题标题】:Error on Scafolding EF Core 1.0 to Existing Db将 EF Core 1.0 搭建到现有数据库时出错
【发布时间】:2016-11-01 19:59:35
【问题描述】:

今天我在 Win 7 上安装了最新版本的 ASP.NET Core 1.0 和 VS2015 Update 3(6 月 27 日发布)。然后按照 MS 文章并在this step of the article 上收到以下错误:

Unable to find expected assembly attribute named DesignTimeProviderServicesAttribute in provider assembly Microsoft.EntityFrameworkCore. This attribute is required to identify the class which acts as the design-time service provider factory.

我的命令如下:

Scaffold-DbContext "Server=MyComputerName\SQL2012;Database=northwind;Trusted_Connection=True;" -OutputDir ".\Models"  Microsoft.EntityFrameworkCore

project.json 文件一节

"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",
    "Microsoft.Extensions.SecretManager.Tools": "1.0.0-preview2-final",
    "Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
      "version": "1.0.0-preview2-final",
      "imports": [
        "portable-net45+win8"
      ]
    }
  },

在带有 SQL Express 2014 的 win 8.1 上,使用上述版本的 ASP.NET Core 和 VS2015 Update 3,我可以成功地按照上述文章中的所有步骤进行操作,而不会出现任何错误。

【问题讨论】:

    标签: visual-studio-2015 ef-code-first asp.net-core entity-framework-core


    【解决方案1】:

    有人帮我指出了我的错误。因为我使用的是 SQL Server,所以我的Scaffold-DbContext 命令中的最后一个参数应该是Microsoft.EntityFrameworkCore.SqlServer。以下作品:

    Scaffold-DbContext "Server=MyComputerName\SQL2012;Database=northwind;Trusted_Connection=True;" -OutputDir ".\Models"  Microsoft.EntityFrameworkCore.SqlServer
    

    【讨论】:

      猜你喜欢
      • 2016-05-19
      • 2019-06-18
      • 2022-12-19
      • 1970-01-01
      • 1970-01-01
      • 2019-10-09
      • 2016-11-11
      • 1970-01-01
      • 2021-03-19
      相关资源
      最近更新 更多