Visual Studio Development Bookmark and Share   
 index > Visual Studio Guidance Automation Toolkit > Add Entity Framework model to Project with GAT
 

Add Entity Framework model to Project with GAT

I need to add an Entity Framework model to a project via GAT and open the Entity Framework model wizard for my developers to create a new model.

My first thought was to create a recipe and reference Microsoft.Data.Entity.Design.VisualStudio.ModelWizard.ModelObjectItemWizard in the Wizard section,  but I get the following exception "Cannot create WizardPage , Constructor on type 'Microsoft.Data.Entity.Design.VisualStudio.ModelWizard.ModelObjectItemWizard' not found". 
 
Alternately,  I attempted to launch the wizard from an Action via DTE.LaunchWizard() but the parameter object array is giving me fits. 
 
Has anyone attempted this?  More generically,  is it possible to launch built in item template wizards when adding items to a project?
sbusi  Tuesday, October 06, 2009 2:34 PM
So I can't reference the ModelObjectItemWizard from a recipe,  so I was forced to tackle the Context Parameters for LaunchWizard and got what I needed.
I still have some tweaking to do,  but this pops my EF Model wizard.  Feel free to comment if any of this code can be optimized or cleaned up.
:

        public override void Execute()
        {
            EnvDTE.DTE dte = (EnvDTE.DTE)GetService(typeof(EnvDTE.DTE));
            EnvDTE80.DTE2 dte2 = Activator.CreateInstance(Type.GetTypeFromProgID("VisualStudio.DTE.9.0")) as EnvDTE80.DTE2;

            string vsWizardAddItem = "{0F90E1D1-4999-11D1-B6D1-00A0C90F2744}";//WizardType Guid
            bool silent = false;

            int commonIndex = dte2.Application.FileName.IndexOf(@"\Common7");
            string vsInstallPath = dte2.Application.FileName.Substring(0,commonIndex);

            Project project = (Project)(((object[])dte.ActiveSolutionProjects)[0]);

            string itemName = project.Name + ".edmx";
            string localDir = System.IO.Path.GetDirectoryName(project.FullName);

            object[] prams = {vsWizardAddItem,project.Name,project.ProjectItems,
                             localDir, itemName,vsInstallPath, silent};

            Solution2 soln = (Solution2)dte2.Solution;
            string templatePath = soln.GetProjectItemTemplate("AdoNetEntityDataModelCSharp.zip", "CSharp");
            dte.LaunchWizard(templatePath, ref prams);
        }


  • Marked As Answer bysbusi Friday, October 09, 2009 9:54 PM
  •  
sbusi  Friday, October 09, 2009 9:53 PM
So I can't reference the ModelObjectItemWizard from a recipe,  so I was forced to tackle the Context Parameters for LaunchWizard and got what I needed.
I still have some tweaking to do,  but this pops my EF Model wizard.  Feel free to comment if any of this code can be optimized or cleaned up.
:

        public override void Execute()
        {
            EnvDTE.DTE dte = (EnvDTE.DTE)GetService(typeof(EnvDTE.DTE));
            EnvDTE80.DTE2 dte2 = Activator.CreateInstance(Type.GetTypeFromProgID("VisualStudio.DTE.9.0")) as EnvDTE80.DTE2;

            string vsWizardAddItem = "{0F90E1D1-4999-11D1-B6D1-00A0C90F2744}";//WizardType Guid
            bool silent = false;

            int commonIndex = dte2.Application.FileName.IndexOf(@"\Common7");
            string vsInstallPath = dte2.Application.FileName.Substring(0,commonIndex);

            Project project = (Project)(((object[])dte.ActiveSolutionProjects)[0]);

            string itemName = project.Name + ".edmx";
            string localDir = System.IO.Path.GetDirectoryName(project.FullName);

            object[] prams = {vsWizardAddItem,project.Name,project.ProjectItems,
                             localDir, itemName,vsInstallPath, silent};

            Solution2 soln = (Solution2)dte2.Solution;
            string templatePath = soln.GetProjectItemTemplate("AdoNetEntityDataModelCSharp.zip", "CSharp");
            dte.LaunchWizard(templatePath, ref prams);
        }


  • Marked As Answer bysbusi Friday, October 09, 2009 9:54 PM
  •  
sbusi  Friday, October 09, 2009 9:53 PM

You can use google to search for other answers

Custom Search

More Threads

• GuidancePackage Solution Will Not build
• Loading solution verty slow
• How to add comment in T4 file
• Is it possible to call an action from a Converter ?
• Input arguments for wizards
• T4 templates editor?
• Creating projects in a subdirectory
• Some doubts about EnvDTE
• Assembly reference in .t4 file
• have GetProjectAction vstemplate to execute a recipe