Mostafa
Mostafa

Reputation: 169

Is controller scaffolding missing in MVC 6?

When creating controller in MVC 6 I don't see the scaffolding for creating controller methods? Will they be missing or in the production release?

Upvotes: 11

Views: 12293

Answers (6)

K7Buoy
K7Buoy

Reputation: 946

It has been painful getting this to work in VS2015 following an upgraded to 1.1 but the following dependencies and tools in your project.json should work if you connecting to SQL to scaffold out your entities too.

{
 "dependencies": {
"Microsoft.EntityFrameworkCore": "1.1.0",
"Microsoft.EntityFrameworkCore.Design": "1.1.0",
"Microsoft.EntityFrameworkCore.SqlServer": "1.1.0",
"Microsoft.EntityFrameworkCore.SqlServer.Design": "1.1.0",
"Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final",
"Microsoft.VisualStudio.Web.CodeGeneration": "1.1.0-preview4-final",
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": "1.1.0-preview4-final",
"Microsoft.VisualStudio.Web.CodeGeneration.EntityFrameworkCore": "1.1.0-preview4-final",
"Microsoft.VisualStudio.Web.CodeGenerators.Mvc": "1.1.0-preview4-final"
},

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

Upvotes: 1

plumdog
plumdog

Reputation: 365

The namespaces have changed in Core 1.0

"Microsoft.VisualStudio.Web.CodeGenerators.Mvc": "1.0.0-preview1-final",
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": "1.0.0-preview1-final"

info from:

https://wildermuth.com/2016/05/17/Converting-an-ASP-NET-Core-RC1-Project-to-RC2

Upvotes: 9

PVIJAY
PVIJAY

Reputation: 95

Doing the following should resolve your issue.

  1. Open VS2015=>TOOLS=>Customize.
  2. Select Commands.
  3. Select Context menu.
  4. Select Project and Solution Context Menus|Folder|Add.
  5. Check that 'Controller' appears.
  6. Move up Controller item to the top.
  7. Restart Visual Studio.

Upvotes: 0

Rick
Rick

Reputation: 278

At least as of the latest Visual Studio 2015 Update 1, ASP.net 5 RC (update1) scaffolding is integrated into Visual Studio.

To do so include the following in your project.json file:

"dependencies": {
    ...
    "Microsoft.Extensions.CodeGenerators.Mvc": "1.0.0-*",
    ...

Then you can find it by right clicking the Controllers directory -> Add -> New Scaffolded Item

Upvotes: 2

Fabio Carello
Fabio Carello

Reputation: 1102

If you are referring to CRUD scaffolding for controllers and views with ASP.NET 5 and MVC 6, it has been split off from the Visual Studio GUI and moved to command line.

You'll need a package called CodeGenerators, add it to your project.json configuration file as:

"dependencies": {
    ...
    "Microsoft.Framework.CodeGenerators.Mvc": "1.0.0-beta4",
    ...
},

At the moment VS does not offer GUI command to perform scaffolding but you can give a look to this link :

ASP.NET 5 (MVC6) Ground Up #4 - Scaffolding CRUD in MVC

Upvotes: 7

Mostafa
Mostafa

Reputation: 169

Command line syntax for scaffolding controllers in MVC 6 is:

dnx . gen controller -name NameOfController --dataContext DBContextName --model NameOfModel

Upvotes: 2

Related Questions