jim crown
jim crown

Reputation: 483

Cannot do database-first model generation

This is how my project.json looks like.

{
  "dependencies": {
    "Microsoft.AspNetCore.Diagnostics": "1.1.1",
    "Microsoft.AspNetCore.Mvc": "1.1.2",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.1.1",
    "Microsoft.AspNetCore.Server.Kestrel": "1.1.1",
    "Microsoft.AspNetCore.StaticFiles": "1.1.1",
    "Microsoft.EntityFrameworkCore.Tools": "1.1.0",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.1",
    "Microsoft.Extensions.Configuration.FileExtensions": "1.1.1",
    "Microsoft.Extensions.Configuration.Json": "1.1.1",
    "Microsoft.Extensions.Logging": "1.1.1",
    "Microsoft.Extensions.Logging.Console": "1.1.1",
    "Microsoft.Extensions.Logging.Debug": "1.1.1",
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.1",
    "Microsoft.NETCore.App": {
      "type": "platform",
      "version": "1.1.1"
    },
    "NLog.Web.AspNetCore": "4.3.1"
  },

  "tools": {
    "Microsoft.EntityFrameworkCore.Tools.DotNet": " 1.1.0-preview4-final"
  },

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

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

  "runtimeOptions": {
    "configProperties": {
      "System.GC.Server": true
    }
  },
  "runtimes": {
    "win8-x64": {}
  },
  "publishOptions": {
    "include": [
      "wwwroot",
      "Views",
      "Areas/**/Views",
      "appsettings.json",
      "web.config",
    ]
  },
  "scripts": {
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  }
}

I am using VS2015 update 3.

enter image description here

I have .NET Core 1.1.1 installed

enter image description here

Here are contents of related folder. enter image description here

Problem is that I am not able to reverse engineer the database. Below is what I am getting when I am running command against my ASP.NET Core project.

PM> Scaffold-DbContext "Server=MY-PC;Database=MyDatabase;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models 
Startup project 'src\MyProject' is an ASP.NET Core or .NET Core project for Visual Studio 2015. This version of the Entity Framework Core Package Manager Console Tools doesn't support these types of projects.

What I am doing wrong here?

Upvotes: 0

Views: 79

Answers (1)

agua from mars
agua from mars

Reputation: 17424

You cannot use Scaffold-DbContext PM because this tool doesn't support VS 2015 project but you can use dotnet ef dbcontext scaffold instead
Entity Framework Core Scaffold DbContext from Existing Database

sample :

dotnet ef dbcontext scaffold "Server=MY-PC;Database=MyDatabase;Trusted_Connection=True;" -o Models Microsoft.EntityFrameworkCore.SqlServer

Upvotes: 1

Related Questions