src/Misc/EFTools/EntityDesign/VisualStudio/VsUtils.cs
// <summary>
//     Ensure the UI context DataSourceWizardSuppressed is set.
//     Ordinarily, when a database file is added to a project, the Data Source
//     Wizard will be initiated offering to create a DataSet from the file.
//     Since we are already creating a .EDMX file based on the database file
//     we need to suppress this wizard.
//     Note: when the wizard checks whether it is suppressed it will reset this
//     context back to "unsuppressed" - so this action needs to be repeated
//     every time we copy in a file.
// </summary>
Ensure the UI context DataSourceWizardSuppressed is set.
Ordinarily, when a database file is added to a project, the Data Source
Wizard will be initiated offering to create a DataSet from the file.
Since we are already creating a .EDMX file based on the database file
we need to suppress this wizard.
Note: when the wizard checks whether it is suppressed it will reset this
context back to "unsuppressed" - so this action needs to be repeated
every time we copy in a file.
Ensure the UI context DataSourceWizardSuppressed is set . Ordinarily when a database file is added to a project the Data Source Wizard will be initiated offering to create a DataSet from the file . Since we are already creating a . EDMX file based on the database file we need to suppress this wizard . Note : when the wizard checks whether it is suppressed it will reset this context back to " unsuppressed " - so this action needs to be repeated every time we copy in a file .
[SuppressMessage("Microsoft.Usage", "CA1806:DoNotIgnoreMethodResults", MessageId = "Microsoft.VisualStudio.Shell.Interop.IVsMonitorSelection.SetCmdUIContext(System.UInt32,System.Int32)")]
        internal static void SetDataSourceWizardSuppressed(IServiceProvider serviceProvider)
        {
            Debug.Assert(null != serviceProvider, "Invalid null serviceProvider specified.");
            if (null != serviceProvider)
            {
                var monitorSelection = serviceProvider.GetService(typeof(SVsShellMonitorSelection)) as IVsMonitorSelection;
                if (monitorSelection != null)
                {
                    var guidCmdUI = VSConstants.UICONTEXT.DataSourceWizardSuppressed_guid;
                    uint dwCmdUICookie;
                    int fActive;
                    if (NativeMethods.Succeeded(monitorSelection.GetCmdUIContextCookie(ref guidCmdUI, out dwCmdUICookie))
                        && NativeMethods.Succeeded(monitorSelection.IsCmdUIContextActive(dwCmdUICookie, out fActive)))
                    {
                        var dataSetWizardIsSuppressed = (fActive != 0);
                        if (!dataSetWizardIsSuppressed)
                        {
                            var hr = monitorSelection.SetCmdUIContext(dwCmdUICookie, 1);
                            Debug.Assert(
                                NativeMethods.Succeeded(hr), "Cannot set DataSourceWizardSuppressed in the UI context. Return code is " + hr);
                        }
                    }
                }
            }
        }
[ SuppressMessage ( " " , " " , MessageId = " " ) ] internal static void SetDataSourceWizardSuppressed ( IServiceProvider serviceProvider ) { Debug . Assert ( null != serviceProvider , " " ) ; if ( null != serviceProvider ) { var monitorSelection = serviceProvider . GetService ( typeof ( SVsShellMonitorSelection ) ) as IVsMonitorSelection ; if ( monitorSelection != null ) { var guidCmdUI = VSConstants . UICONTEXT . DataSourceWizardSuppressed_guid ; uint dwCmdUICookie ; int fActive ; if ( NativeMethods . Succeeded ( monitorSelection . GetCmdUIContextCookie ( ref guidCmdUI , out dwCmdUICookie ) ) && NativeMethods . Succeeded ( monitorSelection . IsCmdUIContextActive ( dwCmdUICookie , out fActive ) ) ) { var dataSetWizardIsSuppressed = ( fActive != 0 ) ; if ( ! dataSetWizardIsSuppressed ) { var hr = monitorSelection . SetCmdUIContext ( dwCmdUICookie , 1 ) ; Debug . Assert ( NativeMethods . Succeeded ( hr ) , " " + hr ) ; } } } } }
Ensure the UI context DataSourceWizardSuppressed is set.
Ensure the UI context DataSourceWizardSuppressed is set .
// If the context is not already active, activate it.
serviceProvider
IServiceProvider