src/Misc/EFTools/EntityDesign/VisualStudio/ModelWizard/DbContextCodeGenerator.cs
// <summary>
//     Finds the DbContext item template path and filename for the given project type.
//     Different paths are returned for C# and VB projects and for normal and Web Site
//     projects. Null is returned if the templates are not installed or the project targets
//     a Framework version without support for T4 code generation.
// </summary>
// <param name="project">The project to which templates will be added.</param>
// <param name="useLegacyTemplate">A value indicating whether to use the legacy version of the template.</param>
// <returns>The template path and file name or null if templates should not be used.</returns>
Finds the DbContext item template path and filename for the given project type.
Different paths are returned for C# and VB projects and for normal and Web Site
projects. Null is returned if the templates are not installed or the project targets
a Framework version without support for T4 code generation.
Finds the DbContext item template path and filename for the given project type . Different paths are returned for C# and VB projects and for normal and Web Site projects . Null is returned if the templates are not installed or the project targets a Framework version without support for T4 code generation .
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
        public string FindDbContextTemplate(Project project, bool useLegacyTemplate = true)
        {
            if (!TemplateSupported(project, Services.ServiceProvider))
            {
                return null;
            }
            var webTag = VsUtils.IsWebSiteProject(project) ? "WS" : "";
            var languageTag = VsUtils.GetLanguageForProject(project) == LangEnum.VisualBasic ? "VB" : "CS";
            var version = useLegacyTemplate ? "5" : "6";
            var templateName = string.Format(CultureInfo.InvariantCulture, _templatePattern, languageTag, webTag, version);
            try
            {
                return ((Solution2)project.DTE.Solution).GetProjectItemTemplate(templateName, project.Kind);
            }
            catch (SystemException)
            {
                return null;
            }
        }
[ SuppressMessage ( " " , " " ) ] public string FindDbContextTemplate ( Project project , bool useLegacyTemplate = true ) { if ( ! TemplateSupported ( project , Services . ServiceProvider ) ) { return null ; } var webTag = VsUtils . IsWebSiteProject ( project ) ? " " : " " ; var languageTag = VsUtils . GetLanguageForProject ( project ) == LangEnum . VisualBasic ? " " : " " ; var version = useLegacyTemplate ? " " : " " ; var templateName = string . Format ( CultureInfo . InvariantCulture , _templatePattern , languageTag , webTag , version ) ; try { return ( ( Solution2 ) project . DTE . Solution ) . GetProjectItemTemplate ( templateName , project . Kind ) ; } catch ( SystemException ) { return null ; } }
Finds the DbContext item template path and filename for the given project type.
Finds the DbContext item template path and filename for the given project type .
// DbContext is not supported on .NET 3.5, so just use built-in ObjectContext code gen. // If the item template is not installed, then silently fall back to build-in // ObjectContext generation. This makes the DbContext generation a light-up feature // that works as soon as the templates are installed.
The template path and file name or null if templates should not be used.
The template path and file name or null if templates should not be used .
project
Project
The project to which templates will be added.
The project to which templates will be added .
useLegacyTemplate
bool
A value indicating whether to use the legacy version of the template.
A value indicating whether to use the legacy version of the template .