Error when scaffolding using Entity Framework Core in ASP.Net core

.net-core asp.net-core asp.net-core-mvc ef-database-first entity-framework-core

Question

I am trying to create models using an existing SQL Server 2016 database. When the run the command prompt as shown in the documentation:

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

I get this error:

Working directory: E:\Personal\TE\VS Projects\EFGetStarted.AspNetCore.ExistingDb\src\EFGetStarted.AspNetCore.ExistingDb
Executing command: dotnet ef --configuration Debug --build-base-path .\bin\ dbcontext scaffold ''Server=techestatevm.southeastasia.cloudapp.azure.com;Database=Blogging;User Id=newuser;Password=pass;''
Microsoft.EntityFrameworkCore.SqlServer --verbose
At line:1 char:215
+ ... user;Password=pass;'' Microsoft.EntityFrameworkCore.SqlServer --verbo ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Unexpected token 'Microsoft.EntityFrameworkCore.SqlServer' in expression or statement.

I have added all the Nuget packages. See my 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%" ]
  }
}
1
0
6/14/2016 7:50:54 PM

Accepted Answer

Looks like this is a documentation issue. The suggestion caution as mentioned in the doc is the culprit. Removing the outer double quotes fixed the issue.

Note that the connection string is double quoted (with single quotes inside the double quotes). This is a workaround for a known issue in RC2 for more details.

1
6/14/2016 6:26:25 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow