3

Based on a class that is used in entity framework I'd like to be able to scaffold other targets than those already present. (mvc controllers, api controllers, views etc.)

For a class Person i would like to be able to generate files like (in my example it would be files for Angular 7)

person.d.ts
person.service.ts
person.component.ts
person.component.html

There does not seem to be any guides on how to add more scaffolding targets, or mayby these guides are hidden by google behind advice on how to modify existing cshtml templates.

To be a bit more specific I'd like to be able to add a menu item on this menu:

Add menu in Visual Studio

Let us call it "Angular Component" similar to "Controller"

And then when choosing it you will get a similar menu to this (without the controller parts):

Add Angular Component

and then be able to create a model, service, component and html template based on the Entity Framework class.

Bent
  • 299
  • 3
  • 10
  • Have a look in [this question](https://stackoverflow.com/questions/38382954/custom-scaffold-templates-in-asp-net-core). Could be a starting point for further research. – Jay Fridge Mar 15 '19 at 11:52
  • @JayFridge Thanks for the tip. But that question is about how to find and edit the templates for existing targets (say a mvc controller). Not about adding new targets. – Bent Mar 15 '19 at 12:51

1 Answers1

1

In Visual studio there is a wizard that's called "Export Template..", you can find it under the project menu. This let's you reverse engineer a project or item template based on an existing class or item.

I think you should be able to create your template using the wizard only. If you want more flexibility however you might have to get into the VSIX project template See: https://learn.microsoft.com/en-us/visualstudio/ide/how-to-create-project-templates?view=vs-2017

Peter
  • 1,361
  • 15
  • 19
  • I will have to look into the "Export Template..." part it might help me. But I am quite sure that a project template is not the way forward. But +1 and thanks for your answer. – Bent Mar 15 '19 at 15:59