简体   繁体   中英

ASP.NET Core Error while using Scaffold-DbContext

I have Visual Studio 2015 and using ASP.NET Core Web API.

I am creating application using database first approach, for that I am using following command in nuget package manager console,

Scaffold-DbContext
    -Connection "'Server=.\SQLEXPRESS;Database=MyERP;Trusted_Connection=True;'"
    -Provider "Microsoft.EntityFrameworkCore.SqlServer" -OutputDir "DBModels"
    -Context "ApplicationDbContext"

After firing this command I am getting following error:

Startup project 'src\\Ang2CoreApi' 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.

First add ASP.NET CORE 1.1.1 runtime and verify that it is installed on the following location

C:/Program files/dotnet/1.1.1 On the above locaion there should be folder named 1.1.1

Then change project.json

"Microsoft.NETCore.App": {

    "version": "1.1.1",

      "type": "platform"

    }

Then after go to your project folder and open cmd there Then fire following command

dotnet ef dbcontext scaffold "Data Source=.\\SQLEXPRESS;Initial Catalog=Demo;Integrated Security=True;" Microsoft.EntityFrameworkCore.SqlServer -o Models/DbEntities

It will create DbEntities folder under Models folder

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM