Locked Add Entity Framework model to Project with GAT

  • Tuesday, October 06, 2009 2:34 PM
     
     
    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?

All Replies

  • Friday, October 09, 2009 9:53 PM
     
     Answered Has Code
    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 by sbusi Friday, October 09, 2009 9:54 PM
    •  
  • Tuesday, July 20, 2010 8:07 PM
     
     
    Can you explain how you able to use Entity Framework on your GAT?  I try to add your code to my action folder and use it in recipe but I got errors. :(
  • Friday, August 06, 2010 2:13 PM
     
      Has Code

    What errors did you get?  My original code was written for VS 2008.   If you want to use it with VS2010, you will need to change

    EnvDTE80.DTE2 dte2 = Activator.CreateInstance(Type.GetTypeFromProgID("VisualStudio.DTE.9.0")) as EnvDTE80.DTE2;
    
    to

    EnvDTE80.DTE2 dte2 = Activator.CreateInstance(Type.GetTypeFromProgID("VisualStudio.DTE.10.0")) as EnvDTE80.DTE2;
    

  • Tuesday, October 19, 2010 4:44 PM
     
     

    Hi, or you could just cast the DTE to DTE2 as following:

     

    var dte2 = this.GetService(typeof(DTE)) as DTE2;

     

    HTH,

    Adrian


    Adrian Alonso - http://adrianalonso.blogspot.com/
  • Wednesday, March 16, 2011 8:33 PM
     
     
    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?

    Could you pls give more explanation on your needs? It will be better for answering your question.