How to add new Scaffold used in Visual Studio 2013 Scaffolding? - powershell

Is there a way to add a new Scaffold or override the Scaffolding functionality used in the new Visual Studio 2013 Scaffolding?
The only documentation I can find on the internet is how to override the T4 templates using the CodeTemplates folder. I want to add a new Scaffold to the list when Add... > New Scaffold Item... It looks like in Visual Studio 2013 this has been rolled into a library (Microsoft.AspNet.Scaffolding.Mvc.5.0.dll) and registered in the GAC or as a VS Extension.
http://weblogs.asp.net/imranbaloch/archive/2013/09/15/customizing-the-asp-net-mvc-5-web-api-2-scaffolding-templates.aspx?CommentPosted=true#commentmessage
I want to override the mechanism that calls the T4 templates so I can create different files and enhanced the functionality. My specific need is that I want to scaffold the old CreateOrEdit.cshtml and a new DetailsOrDelete.chtml partial views. I would also like to Scaffold a tool that takes a resource file and generates the localized resource file in another language.

In Visual Studio 2013 RTM there is no support for adding completely custom scaffolders. You can only do the following customizations:
You can edit or override the existing T4 templates for controllers, areas, views, etc.
You can add custom view scaffolders that will show up in the existing MVC View scaffolder
The Visual Studio team is working on re-enabling custom scaffolder support in a future update of Visual Studio.
To add a custom view scaffolder today:
Create any ASP.NET project in VS2013
Add a folder called CodeTemplates
Create a sub-folder in there called either MvcView or MvcViewWithoutModel depending on whether your custom view template is a strongly-typed view
Create a file there in the form of <templatename>.<lang>.t4 where the <templatename> is whatever you want to show up in the MVC View scaffolder's drop down list and <lang> is either cs or vb.
To get started you can copy any existing scaffolder from VS2013's default list and customize it. You can get the built-in scaffolders from here:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\Web\Mvc\Scaffolding\Templates\MvcView
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\Web\Mvc\Scaffolding\Templates\MvcViewWithoutModel
If you use the same name as an existing scaffolder then it will override the built-in scaffolder, even when called from another scaffolder. For example, the MVC controller scaffolder will use an overridden view scaffolder that is in your project.
4/22/2014 Update
Now that previews of Visual Studio 2013 Update 2 are available, it is possible to write completely custom scaffolders.
Check out this blog post that walks through how to write a custom scaffolder: Creating a Custom Scaffolder for Visual Studio

Related

Entity Framework DTO generator for Visual Studio 2019

Currenty I am using an Entity Framework DTO generator called EntitiesToDTOs (see here and here) in Visual Studio 2013. Now I have upgraded to Visual Studio 2019 and this addin is not supported so is there any other similar tool to generate DTOs, and also convert Entity to DTO and viceversa?
Try this extension DTO Writer
Simple code generation tool for DTO-classes creation. You can easily create DTO-classes for your models in three clicks:
Make right mouse click in Solution Explorer on your .cs file that contains model classes.
Click "Create DTO" in context menu (You can find the same menu item in context menu of code editor area).
Click "OK" in creator dialog window.

Multiple Visual Studio Projects in Unity

I am trying to move all of my non Unity-specific code into classes which don't inherit from MonoBehaviour, similar to this. I created a separate Visual Studio project called Models for all of my non-MonoBehaviour classes, and I added that project to the Visual Studio solution. However, I can't add a reference to my Models project to my Unity project through Visual Studio (the Add Reference button isn't there when I click on the Unity project, and I've read that Unity automatically rebuilds its Visual Studio project anyway, so any added references would be lost), so I set the output location of my Models .dll to the Assets folder in Unity and I added that .dll to my Project view in Unity. That's all working. The problem is that whenever I rebuild my Models project, the Unity project in Visual Studio doesn't seem to pick up the changes, so I have to delete the .dll from the Project view in Unity and re-add it every time I make any changes to the Models project.
Is there a way to have Visual Studio automatically see the changes to my Models .dll, or is there a better way to go about having my Unity project reference another Visual Studio project?
I tried researching this for you, and the closest thing i could find so far is this: http://devleader.ca/2015/02/08/multiple-c-projects-unity-3d-solution/
It details how to adopt unity and visual studio to work well and sync up correctly without rebuilding/running/other crazy things to get the projects working together.
Hope it helps.

ajax toolkit controls grayed out due to designer compatability or framework

I have converted my project from visual studio 2005 to Visual studio 2012. I am using.Net frmawork version 4.5.and i want to add ajax control toolkit in my project.i have created new control with named ajax and add items from browsing ajax toolkit 4.5.after clicking ok popup is displayed showing controls are added sucessfully but make sure framework version and design compatability.please give me a solution.i have tried all solutions.
I got solution for this issue,Goto property pages and in build option select appropriate version on ajax control toolkit

Visual Studio T4 - include file using environment variable

I have some T4 templates set up which reference other shared T4s. One T4 references another like this:
<## include file="%MTF%\DAL\Models\DALContextGenerator.tt"#>
This works fine except MTF has to be defined as an environment variable at the operating system level - I want to define this somewhere in the solution itself - or in each project within the solution if I have to. I've tried editing the CSPROJ file and adding an entry under , but the T4 engine doesn't seem to pick that up. I also tried creating a C++ property sheet and adding it there as a macro, but again the T4 engine (from inside a C# project) can't see it either.
Thanks in advance for any tips,
Ray
I'm afraid there is no way to do this in the current version of Visual Studio.
I haven't tried it myself, but in the Visual Studio documentation there is a section on how to use project properties in T4 include directives:

Add new item in Visual Studio

In eclipse the Add New Class wizard lets you specify all sorts of options, such as what modifiers the class has, what interfaces it implements, what its parent class(es) is, what package it resides in, etc.
Comparatively the default add new item wizard in visual studio while offering a large selection of templates does not offer such options.
Is there any way to get eclipse like functionality in Visual Studio through some setting or extension?
Visual Studio should have those capabilities right off the start, I would suggest going through the different menu such as Views, projects etc. take a look at this
http://msdn.microsoft.com/en-us/vstudio/cc136611.aspx if your new that is
Visual Studio has a different way of handling things. You add the class and then use the refactor menu to add any interfaces, etc. Right click on the class name -> refactor, or you can use the refactor menu.