在核心中使用实体框架核心 ASP.Net 基架时出错



我正在尝试使用现有的SQL Server 2016数据库创建模型。当运行命令提示符时,如文档所示:

PM> Scaffold-DbContext "'Server=techestatevm.southeastasia.cloudapp.azure.com;Database=Blogging;User Id=newuser;Password=pass;'" Microsoft.EntityFrameworkCore.SqlServer -verbose

我收到此错误:

工作目录: E:\Personal\TE\VS Projects\EFGetStarted.AspNetCore.ExistingDb\

src\EFGetStarted.AspNetCore.ExistingDb
正在执行命令: dotnet ef --configuration Debug --build-base-path .\bin\ dbcontext scaffold ''Server=techestatevm.southeastasia.cloudapp.azure.com;Database=Blogging;用户 ID = 新用户;密码=通过;"
Microsoft.EntityFrameworkCore.SqlServer --verbose
行:1 字符:215
+ ...用户;密码=通过;"Microsoft.EntityFrameworkCore.SqlServer --verbo ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 表达式或语句中意外的标记"Microsoft.EntityFrameworkCore.SqlServer"。

我已经添加了所有Nuget包。查看我的project.json

{
  "dependencies": {
    "Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final",
    "Microsoft.EntityFrameworkCore": "1.0.0-rc2-final",
    "Microsoft.EntityFrameworkCore.InMemory": "1.0.0-rc2-final",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0-rc2-final",
    "Microsoft.EntityFrameworkCore.SqlServer.Design": "1.0.0-rc2-final",
    "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview1-final",
    "Microsoft.EntityFrameworkCore.Tools.Cli": "1.0.0-preview1-final",
    "Microsoft.EntityFrameworkCore.Tools.Core": "1.0.0-rc2-final",
    "Microsoft.VisualStudio.Web.CodeGeneration.EntityFrameworkCore": "1.0.0-preview1-final"
  },
  "tools": {
    "Microsoft.EntityFrameworkCore.Tools": {
      "version": "1.0.0-preview1-final",
      "imports": [
        "portable-net45+win8+dnxcore50",
        "portable-net45+win8"
      ]
    },
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": {
      "version": "1.0.0-preview1-final",
      "imports": "portable-net45+win8+dnxcore50"
    }
  },
  "frameworks": {
    "net452": { }
  },
  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },
  "publishOptions": {
    "include": [
      "wwwroot",
      "web.config"
    ]
  },
  "scripts": {
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  }
}

看起来这是一个文档问题。文档中提到的建议警告是罪魁祸首。删除外部双引号解决了该问题。

请注意,连接字符串是双引号(双引号内有单引号)。这是 RC2 中已知问题的解决方法,以获取更多详细信息。

相关内容

  • 没有找到相关文章

最新更新