src/Misc/EFTools/EntityDesign/VisualStudio/RetargetingHandler.cs
// <summary>
//     Project retargeting event handler.
//     1. Check the project type, return immediately if project is misc project or a project that does not support EF.
//     2. Find all the EDMX files in the project. Skip Data Services edmx files and linked files.
//     3. Sync all the namespaces based on the new target framework
// </summary>
Project retargeting event handler.
1. Check the project type, return immediately if project is misc project or a project that does not support EF.
2. Find all the EDMX files in the project. Skip Data Services edmx files and linked files.
3. Sync all the namespaces based on the new target framework
Project retargeting event handler . 1 . Check the project type return immediately if project is misc project or a project that does not support EF . 2 . Find all the EDMX files in the project . Skip Data Services edmx files and linked files . 3 . Sync all the namespaces based on the new target framework
public void RetargetFilesInProject()
        {
            var project = VSHelpers.GetProject(_hierarchy);
            if (project == null
                || !VsUtils.EntityFrameworkSupportedInProject(project, _serviceProvider, allowMiscProject: false))
            {
                return;
            }
            var targetSchemaVersion = EdmUtils.GetEntityFrameworkVersion(project, _serviceProvider, useLatestIfNoEF: false);
            Debug.Assert(targetSchemaVersion != null, "schema version must not be null for projects that support EF");
            var documentMap = new Dictionary<string, object>();
            foreach (var vsFileInfo in GetEdmxFileInfos())
            {
                try
                {
                    var projectItem = VsUtils.GetProjectItem(_hierarchy, vsFileInfo.ItemId);
                    if (IsDataServicesEdmx(projectItem.get_FileNames(1))
                        || VsUtils.IsLinkProjectItem(projectItem))
                    {
                        continue;
                    }
                    var doc = RetargetFile(vsFileInfo.Path, targetSchemaVersion);
                    if (doc != null)
                    {
                        documentMap.Add(vsFileInfo.Path, doc);
                    }
                }
                catch (Exception ex)
                {
                    VsUtils.LogStandardError(
                        string.Format(CultureInfo.CurrentCulture, Resources.ErrorSynchingEdmxNamespaces, vsFileInfo.Path, ex.Message),
                        vsFileInfo.Path, 0, 0);
                    throw;
                }
            }
            WriteModifiedFiles(project, documentMap);
        }
public void RetargetFilesInProject ( ) { var project = VSHelpers . GetProject ( _hierarchy ) ; if ( project == null || ! VsUtils . EntityFrameworkSupportedInProject ( project , _serviceProvider , allowMiscProject : false ) ) { return ; } var targetSchemaVersion = EdmUtils . GetEntityFrameworkVersion ( project , _serviceProvider , useLatestIfNoEF : false ) ; Debug . Assert ( targetSchemaVersion != null , " " ) ; var documentMap = new Dictionary < string , object > ( ) ; foreach ( var vsFileInfo in GetEdmxFileInfos ( ) ) { try { var projectItem = VsUtils . GetProjectItem ( _hierarchy , vsFileInfo . ItemId ) ; if ( IsDataServicesEdmx ( projectItem . get_FileNames ( 1 ) ) || VsUtils . IsLinkProjectItem ( projectItem ) ) { continue ; } var doc = RetargetFile ( vsFileInfo . Path , targetSchemaVersion ) ; if ( doc != null ) { documentMap . Add ( vsFileInfo . Path , doc ) ; } } catch ( Exception ex ) { VsUtils . LogStandardError ( string . Format ( CultureInfo . CurrentCulture , Resources . ErrorSynchingEdmxNamespaces , vsFileInfo . Path , ex . Message ) , vsFileInfo . Path , 0 , 0 ) ; throw ; } } WriteModifiedFiles ( project , documentMap ) ; }
Project retargeting event handler.
Project retargeting event handler .
// skip the process for astoria edmx file or a linked edmx file // TODO: When there is an exception; should we continue?