src/Misc/EFTools/EntityDesign/VisualStudio/ModelWizard/engine/ConfigFileHelper.cs
// <summary>
//     Updates app. or web.config to include connection strings, registers the build provider
//     for WebSite projects and the assembly for WebApp projects
// </summary>
Updates app. or web.config to include connection strings, registers the build provider
for WebSite projects and the assembly for WebApp projects
Updates app . or web . config to include connection strings registers the build provider for WebSite projects and the assembly for WebApp projects
internal static void UpdateConfig(ModelBuilderSettings settings)
        {
            var metadataFileNames = 
                ConnectionManager.GetMetadataFileNamesFromArtifactFileName(settings.Project, settings.ModelPath, PackageManager.Package);
            if (settings.GenerationOption == ModelGenerationOption.GenerateFromDatabase
                || settings.GenerationOption == ModelGenerationOption.GenerateDatabaseScript)
            {
                if (settings.SaveConnectionStringInAppConfig)
                {
                    UpdateConfig(metadataFileNames, settings);
                }
            }
            if (settings.VSApplicationType == VisualStudioProjectSystem.Website)
            {
                var containingProject = settings.Project;
                RegisterBuildProvidersInWebConfig(containingProject);
                var targetInfo = PackageManager.Package.GetService(typeof(SVsFrameworkMultiTargeting)) as IVsFrameworkMultiTargeting;
                var openScope = PackageManager.Package.GetService(typeof(SVsSmartOpenScope)) as IVsSmartOpenScope;
                Debug.Assert(targetInfo != null, "Unable to get IVsFrameworkMultiTargeting from service provider");
                if (targetInfo != null && openScope != null)
                {
                    var targetFrameworkMoniker = VsUtils.GetTargetFrameworkMonikerForProject(containingProject, PackageManager.Package);
                    var provider = new VsTargetFrameworkProvider(targetInfo, targetFrameworkMoniker, openScope);
                    var dataEntityDesignAssembly = provider.GetReflectionAssembly(new AssemblyName("System.Data.Entity.Design"));
                    if (dataEntityDesignAssembly != null)
                    {
                        RegisterAssemblyInWebConfig(containingProject, dataEntityDesignAssembly.FullName);
                    }
                }
            }
        }
internal static void UpdateConfig ( ModelBuilderSettings settings ) { var metadataFileNames = ConnectionManager . GetMetadataFileNamesFromArtifactFileName ( settings . Project , settings . ModelPath , PackageManager . Package ) ; if ( settings . GenerationOption == ModelGenerationOption . GenerateFromDatabase || settings . GenerationOption == ModelGenerationOption . GenerateDatabaseScript ) { if ( settings . SaveConnectionStringInAppConfig ) { UpdateConfig ( metadataFileNames , settings ) ; } } if ( settings . VSApplicationType == VisualStudioProjectSystem . Website ) { var containingProject = settings . Project ; RegisterBuildProvidersInWebConfig ( containingProject ) ; var targetInfo = PackageManager . Package . GetService ( typeof ( SVsFrameworkMultiTargeting ) ) as IVsFrameworkMultiTargeting ; var openScope = PackageManager . Package . GetService ( typeof ( SVsSmartOpenScope ) ) as IVsSmartOpenScope ; Debug . Assert ( targetInfo != null , " " ) ; if ( targetInfo != null && openScope != null ) { var targetFrameworkMoniker = VsUtils . GetTargetFrameworkMonikerForProject ( containingProject , PackageManager . Package ) ; var provider = new VsTargetFrameworkProvider ( targetInfo , targetFrameworkMoniker , openScope ) ; var dataEntityDesignAssembly = provider . GetReflectionAssembly ( new AssemblyName ( " " ) ) ; if ( dataEntityDesignAssembly != null ) { RegisterAssemblyInWebConfig ( containingProject , dataEntityDesignAssembly . FullName ) ; } } } }
Updates app.
Updates app .
// regardless of GenerationOption we always need to register the build // provider for web site projects and the assembly for web app projects // Ensure that System.Data.Entity.Design reference assemblies are added in the web.config. // Get the correct assembly name based on target framework
settings
ModelBuilderSettings