Reputation: 2099
I'm using ASP.NET Beta 8 trying to get scaffolding to work but it getting an issue with the Microsoft.Framework.CodeGeneration
My project.json
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel",
"ef": "EntityFramework.Commands",
"gen": "Microsoft.Framework.CodeGeneration"
},
Command :
dnx gen controller -Name ModelClassName--datacontext MyDbContext --model ModelClassName
Error:
dnx : Error: Unable to load application or execute command 'Microsoft.Framework.CodeGeneration'. Available commands: web, ef, gen.
This package is on Nuget but it hasn't been updated for Beta 8.
Only version is Beta 5. Link
When I install this Beta 5 package
Install-Package Microsoft.Framework.CodeGeneration -Pre
and run the same scaffolding command I get the error:
Unable to resolve service for type 'Microsoft.Framework.Runtime.ILibraryManager'
This makes me think scaffolding doesn't work in Beta 8.
Upvotes: 4
Views: 634
Reputation: 1
In Visual Studio 2015, you should add a package source that points to aspnetmaster.
Go to Tools->Options->NuGet Package Manager->Package Sources Add a new package name it whatever you like ex. mygetv3 an set the source to https://www.myget.org/F/aspnetmaster/api/v3/index.json
Place it first in the list.
In project.json -> "dependencies" add "Microsoft.Framework.CodeGenerators.Mvc": "1.0.0-beta8" and in "commands" add "gen": "Microsoft.Framework.CodeGeneration"
now you can use it as you did in beta5 ex.:
dnx gen controller -name NameController --dataContext DbContext --model ModelName -l _Layout -f
Upvotes: 0
Reputation: 143
In rc-update1, the namespaces have changed:
FROM: Microsoft.Framework.CodeGeneration
TO: Microsoft.Extensions.CodeGeneration
So instead of installing Microsoft.Framework.CodeGeneration
, just add Microsoft.Extensions.CodeGenerators.Mvc
to your project.json
project.json
"dependencies": {
...
"Microsoft.Extensions.CodeGenerators.Mvc": "1.0.0-rc1-final",
}
"commands": {
...
"gen": "Microsoft.Extensions.CodeGeneration"
}
Customizing the MVC6 scaffolding templates
To customize the MVC6 scaffolding templates, you will find them in the folder: C:\Users\ {user}
.dnx\packages\Microsoft.Extensions.CodeGenerators.Mvc\ 1.0.0-rc1-final
\Templates
To create a project specific set of templates, just copy the Templates folder into the root folder of your project (i.e. same folder as project.json) and when you use dnx gen scaffolding
it will use these locally customised templates
Upvotes: 0
Reputation: 2099
Working scaffolding wasn't included in BETA 8. It was fixed again in RC1
Upvotes: 0
Reputation: 394
for all using rc1-final just change the namespace in commands to
"gen": "Microsoft.Extensions.CodeGeneration"
Upvotes: 5
Reputation: 13709
Beta 5 packages should not be mixed with Beta 8.
This package seem to not have been updated which means that this code is technically dead and/or has been merged in another DNX project. I've seen ILibraryManager
in the Microsoft.Extensions.PlatformAbstractions
namespace.
As said in my comment, you probably have a version mismatch. Ensure to use 1.0.0-beta8
package specifically (no 1.0.0-*
). I would do a File > New Project
with the beta8 and check what the gen
command is using in the new template.
Upvotes: 0