For example, if you are using Visual Studio 2017 Professional Edition, your path may be like below.
“C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\WebTemplates\MVC\CSharp\1033”
Important
We are going to modify some files and add some files to this folder. Please be careful to take a backup of this path before going to make any changes.
You can see the below folders and files inside the above folder.
- The “MvcApplicationTestLibaryv5.0” folder is used for test projects.
- The “MvcBasicApplicationv5.0” folder is used for MVC 5.0 projects.
- The “MvcEmptyTestLibaryv5.0” folder is also used for test projects and “Spav5.0” used for single page application projects.
- You can see the “Mvc.png” image file which is used as a preview icon for all the templates.
- There is one more file, “Templates.xml” in the folder. This is the most important file used to control the entire project templates.
We can copy the folder “MvcBasicApplicationv5.0” and rename to “MvcEntityApplicationv5.0”.
Now, open this folder.
You can see many folders and files inside the above folder. “MvcBasicApplication.cshtml.vstemplate” is the project template file which will control the default packages for an MVC project file. We can rename this file to “MvcEntityApplication.cshtml.vstemplate” for uniqueness.
We can open this file and add some values to this file. You can see many sections inside this template file.
The last section is the “WizardData” section and you can see the default package details inside it. Please note these are the default package libraries added with an MVC project. We can add one more package reference inside this section for Entity Framework.
I have added a new reference. Please note that you can’t add all the references inside this section. The package should be in the below file location.
“C:\Program Files (x86)\Microsoft Visual Studio\Shared\Packages”
The above folder is common for all Visual Studio versions. If you are adding a new package which is not in the above folder location, Visual Studio will throw an error while creating the project.
MvcEntityApplication.cshtml.vstemplate
- <VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Project">
- <TemplateData>
- <ProjectType>CSharp</ProjectType>
- <ProjectSubType>Web</ProjectSubType>
- <TemplateGroupID>Web</TemplateGroupID>
- <TemplateID>Microsoft.WAP.CSharp.MvcBasicApplication.v5</TemplateID>
- <SortOrder>51</SortOrder>
- <RequiredFrameworkVersion>4.5</RequiredFrameworkVersion>
- <CreateNewFolder>true</CreateNewFolder>
- <DefaultName>MvcApplication</DefaultName>
- <ProvideDefaultName>true</ProvideDefaultName>
- <LocationField>Enabled</LocationField>
- <PromptForSaveOnCreation>true</PromptForSaveOnCreation>
- <EnableLocationBrowseButton>true</EnableLocationBrowseButton>
- </TemplateData>
- <TemplateContent>
- <CustomParameters>
- <CustomParameter Name="$language$" Value="C#" />
- <CustomParameter Name="$languageext$" Value="cs" />
- <CustomParameter Name="$globalclassname$" Value="MvcApplication" />
- </CustomParameters>
- <Project File="MvcBasicApplication.csproj" ReplaceParameters="true">
- <ProjectItem ReplaceParameters="false" TargetFileName="favicon.ico">favicon.ico</ProjectItem>
- <Folder Name="Properties" TargetFolderName="Properties">
- <ProjectItem ReplaceParameters="true" TargetFileName="AssemblyInfo.cs">AssemblyInfo.cs</ProjectItem>
- </Folder>
- <Folder Name="App_Data" TargetFolderName="App_Data" />
- <Folder Name="App_Start" TargetFolderName="App_Start">
- <ProjectItem ReplaceParameters="true" TargetFileName="BundleConfig.cs">BundleConfig.cs</ProjectItem>
- <ProjectItem ReplaceParameters="true" TargetFileName="FilterConfig.cs">FilterConfig.cs</ProjectItem>
- <ProjectItem ReplaceParameters="true" TargetFileName="RouteConfig.cs">RouteConfig.cs</ProjectItem>
- </Folder>
- <Folder Name="Content" TargetFolderName="Content">
- <ProjectItem ReplaceParameters="true" TargetFileName="Site.css">Site.css</ProjectItem>
- </Folder>
- <Folder Name="Controllers" TargetFolderName="Controllers">
- <ProjectItem ReplaceParameters="true" TargetFileName="HomeController.cs">HomeController.cs</ProjectItem>
- </Folder>
- <Folder Name="Models" TargetFolderName="Models" />
- <Folder Name="Scripts" TargetFolderName="Scripts" />
- <Folder Name="Views" TargetFolderName="Views">
- <Folder Name="Home" TargetFolderName="Home">
- <ProjectItem ReplaceParameters="true" TargetFileName="About.cshtml">About.cshtml</ProjectItem>
- <ProjectItem ReplaceParameters="true" TargetFileName="Contact.cshtml">Contact.cshtml</ProjectItem>
- <ProjectItem ReplaceParameters="true" TargetFileName="Index.cshtml">Index.cshtml</ProjectItem>
- </Folder>
- <Folder Name="Shared" TargetFolderName="Shared">
- <ProjectItem ReplaceParameters="true" TargetFileName="_Layout.cshtml">_Layout.cshtml</ProjectItem>
- <ProjectItem ReplaceParameters="true" TargetFileName="Error.cshtml">Error.cshtml</ProjectItem>
- </Folder>
- <ProjectItem ReplaceParameters="true" TargetFileName="_ViewStart.cshtml">_ViewStart.cshtml</ProjectItem>
- <ProjectItem ReplaceParameters="true" TargetFileName="Web.config">Web.config</ProjectItem>
- </Folder>
- <ProjectItem ReplaceParameters="true" TargetFileName="Global.asax">Global.asax</ProjectItem>
- <ProjectItem ReplaceParameters="true" TargetFileName="Global.asax.cs">Global.asax.cs</ProjectItem>
- <ProjectItem ReplaceParameters="true" TargetFileName="Web.config">Web.config</ProjectItem>
- <ProjectItem ReplaceParameters="true" TargetFileName="Web.Debug.config">Web.Debug.config</ProjectItem>
- <ProjectItem ReplaceParameters="true" TargetFileName="Web.Release.config">Web.Release.config</ProjectItem>
- </Project>
- </TemplateContent>
- <WizardExtension>
- <Assembly>NuGet.VisualStudio.Interop, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</Assembly>
- <FullClassName>NuGet.VisualStudio.TemplateWizard</FullClassName>
- </WizardExtension>
- <WizardData>
- <packages repository="registry" keyName="WebFormsVS16" isPreunzipped="true">
- <package id="Newtonsoft.Json" version="11.0.1" skipAssemblyReferences="true" />
- <package id="bootstrap" version="3.4.1" skipAssemblyReferences="true" />
- <package id="EntityFramework" version="6.2.0" skipAssemblyReferences="true" />
- <package id="jQuery" version="3.3.1" skipAssemblyReferences="true" />
- <package id="Microsoft.AspNet.Razor" version="3.2.7" skipAssemblyReferences="true" />
- <package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" skipAssemblyReferences="true" />
- <package id="Microsoft.AspNet.WebPages" version="3.2.7" skipAssemblyReferences="true" />
- <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" skipAssemblyReferences="true" />
- <package id="Microsoft.AspNet.Mvc" version="5.2.7" skipAssemblyReferences="true" />
- <package id="Modernizr" version="2.8.3" skipAssemblyReferences="true" />
- <package id="Antlr" version="3.5.0.2" skipAssemblyReferences="true" />
- <package id="WebGrease" version="1.6.0" skipAssemblyReferences="true" />
- <package id="jQuery.Validation" version="1.17.0" skipAssemblyReferences="true"/>
- <package id="Microsoft.jQuery.Unobtrusive.Validation" version="3.2.11" skipAssemblyReferences="true"/>
-
- </packages>
- </WizardData>
- </VSTemplate>