I need to create a project template for our team. And I also want to automate display the EDM Wizard while start create the project. So after the project is generate, there will have a EDMX file.
So, I wrote a Wizard and to add some replacement parameters which will not added into because it is a project template.
But even those parameters are added, the EDM Wizard still shows error "Key cannot be none".
So, what should I do to complete this?
<VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="ProjectGroup"><TemplateData><Name>Framework Application</Name><Description>Create the application by using the RDC framework.</Description><Icon>__TemplateIcon.ico</Icon><ProjectType>CSharp</ProjectType><ProjectSubType></ProjectSubType><SortOrder>1000</SortOrder><DefaultName>Application</DefaultName><ProvideDefaultName>true</ProvideDefaultName><LocationField>Enabled</LocationField><EnableLocationBrowseButton>true</EnableLocationBrowseButton><NumberOfParentCategoriesToRollUp>1</NumberOfParentCategoriesToRollUp></TemplateData><TemplateContent><ProjectCollection><SolutionFolder Name="Common"><ProjectTemplateLink ProjectName="$safeprojectname$.Common"> Common\MyTemplate.vstemplate</ProjectTemplateLink></SolutionFolder><SolutionFolder Name="Server-Side"><ProjectTemplateLink ProjectName="$safeprojectname$.Data"> Data\MyTemplate.vstemplate</ProjectTemplateLink></SolutionFolder></ProjectCollection><ProjectItem OpenInEditor="false" SubType="" TargetFileName="$safeprojectname$.edmx" ReplaceParameters="true">ProjectItem.edmx</ProjectItem><ProjectItem OpenInEditor="false" TargetFileName="$safeprojectname$.edmx.diagram" ReplaceParameters="true">ProjectItem.edmx.diagram</ProjectItem></TemplateContent><WizardExtension><Assembly>TemplateWizards, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ca0848d49e6d9d2a</Assembly><FullClassName>FrameworkWizard</FullClassName></WizardExtension>
<WizardExtension>
<Assembly>Microsoft.Data.Entity.Design, Version=11.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</Assembly><FullClassName>Microsoft.Data.Entity.Design.VisualStudio.ModelWizard.ModelObjectItemWizard</FullClassName></WizardExtension>
</VSTemplate>
replacementsDictionary.Add("$safeitemname$", replacementsDictionary["$safeprojectname$"] + "Model.edmx"); replacementsDictionary.Add("$itemname$", replacementsDictionary["$safeprojectname$"] + "Model.edmx"); replacementsDictionary.Add("$rootname$", replacementsDictionary["$safeprojectname$"] + "Model.edmx"); replacementsDictionary.Add("$rootnamespace$", replacementsDictionary["$safeprojectname$"] + ".Data");
The reason that we don't use the EDMGen.exe, is that: in our project, we use some T4 Template (in the Common project as the template XML shows) to generate some code. So, we need use the EDMX file. which EDMGen.exe will not generate. And I'd like
to let the customer to choose which table and view they like to add into the project.
MetadataLoader loader = new MetadataLoader(this); string inputFile = @"..\Model.edmx"; bool allMetadataLoaded = loader.TryLoadAllMetadata(inputFile, out metadataWorkspace);
If there have some way that I can launch the EDM Wizard in C# code, it will also good for me...
Any idea is appreciate.