Scafolding EF Core 1.0到现有Db的错误

时间:2016-06-29 22:17:24

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

今天我在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版本,我可以成功地完成上述文章中的所有步骤而不会出现任何错误。

1 个答案:

答案 0 :(得分:0)

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

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