Visual Studio Developer Center >
Visual Studio Forums
>
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?
Answers
- 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
All Replies
- 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


