Adding a custom t4 template to DDL Generation Template dropdownlist - entity-framework-5

I know I can add the template in the folder
C:\Program Files (x86)\Microsoft Visual Studio
11.0\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\DBGen
to make it visible in the DDL Generation Template dropdownlist, but then I need to distribute the template to my team members so they can add the template to the same folder.
I was hoping that I could achieve the same result by adding the template to the VS 2012 solution somehow and make it visible in the same dropdownlist
Do you know a way to achieve this?
I'm using VS 2012 and to generate the database I use Model First approach

I played around with this tonight and found it is possible, but it's kind of a hack. You'll have to edit your edmx file by hand, and make sure it is version controlled because you have to edit the designer section of the edmx file (auto-generated). First thing is to copy the t4 template to the root of your project (might actually have to be in the same folder as the edmx, not sure). Then add the t4 template to your project. Now remove the custom tool entry (in properties) so it doesn't try and auto gen the t4 template. finally add the designer property below in the correct location in the edmx file (i included context to find the right place):
<!-- EF Designer content (DO NOT EDIT MANUALLY BELOW HERE) -->
<edmx:Designer xmlns="http://schemas.microsoft.com/ado/2009/11/edmx">
<edmx:Options>
<DesignerInfoPropertySet>
<DesignerProperty Name="DDLGenerationTemplate" Value="SSDLToSQLite3.tt" />

I ended up making a custom template to generate datetime2 fields. Although I could not get the template to show in the drop down in the properties box, I was able to add the template to the same folder as my .edmx, include it in the solution, then type the file name of the template directly into the designer's property field replacing the default. The value appears to be retained after generating databases and entities, I didn't need to directly edit the edmx XML, and my custom template is now source controlled right next to where it is used.

Related

Biztalk template with non-static namespace - Visual Studio

I've exported an orchestration template using Visual Studio 2012, based on one I previously constructed. It generates a .zip with the following .vstemplate file:
<VSTemplate Type="Item" Version="2.0.0"
xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
<TemplateData>
<Name>TESTOrchestration</Name>
<Description>Custon Orchestration</Description>
<Icon>Icon.ico</Icon>
<ProjectType>Biztalk</ProjectType>
<DefaultName>TESTOrchestration.odx</DefaultName>
</TemplateData>
<TemplateContent>
<ProjectItem TargetFileName="$fileinputname$.odx" ReplaceParameters="true">Orchestration.odx</ProjectItem>
</TemplateContent>
Using this item template in VS2012 creates an orchestration with the properties shown in the fig. below.
Notice the namespace is that of the original project from which the template was exported.
I want to set the default namespace of this item to include the project name (or even better the path leading to this item within the project). After searching I've yet to find a working example of how to accomplish this in a BizTalk item, namely an .odx.
Thank you for taking the time to read my question. I really hope you will be able to help me with this.
After searching and tinkering around I found out how to accomplish this.
When you export a template from Visual Studio two files are created, a .vstemplate and a template of the exported item, in this case a .odx. In order to alter the namespace, and other attributes, you need to edit this second file and add the information you want.
It is also possible to pass dynamic values by using template parameters in the form of $parameter$, which are documented in Microsoft's library.
So, for example, if you wanted to modify the namespace to include the project name, you would have to edit the exported .odx file and add the parameter $safeprojectname$ or $rootnamespace$ to dynamically set the namespace uppon creation of a new item based on the template.

Sharepoint Infopath form - How to tell if custom code eixsts

I'm working with a Sharepoint project that was migrated from 2007 to 2010. There is not history on who originally created the project or how they did this. So, if the original developer used a Visual Studio project to add custom code to the form, that VS project does not exist.
Is there any way to tell if an existing form has custom code written for it? If I want to add my own custom code, the only way I can do this is go into the form properties and select "remove existing code". Then I can create a new project and add code.
Is it the case that if I cannot find the original VS project, that this is my only choice...to remove any existing code?
Yes, if you can't find the original project, then you're out of luck - you have to remove the code and rewrite as necessary.
http://www.bizsupportonline.net/blog/2013/recover-make-changes-infopath-forms-sharepoint.htm
(Paragraph at the bottom of the article, just before "3 ways you can find out whether code was written for a form template")

Which Visual Studio project types support Shift+Alt+D to open the Data Sources window?

In Visual Studio 2012, it appears that only maybe a third of the 20 or so C# project types support using Shift+Alt+D to open the "Data Sources" window (and none that I've found ever display the mythical "Data" menu bar option).
Is there any sort of guide as to which project types will allow you to work with data sources?
Also, is there any way to "adjust" the features of a project after it's been created?
Update: See my answer below for how to add the Data Sources function to an existing project.
I believe you are looking for this page:
http://msdn.microsoft.com/en-us/library/yft2c9ad.aspx
To quote msdn: "You can add a data source to a project only if it supports creating and working with data sources. For example, you can't open the Data Sources window in a project for a Windows Store app."
Basically, if using a database seems logical in your application, you can probably use one.
To answer your question about the "mythical 'Data' menu bar option", here's how you access it:
You just have to select "View", then "Other Windows", and finally "Data Sources"
And to answer your final question about, "Also, is there any way to 'adjust' the features of a project after it's been created?"
Yes, yes there is. If you mean as a compiled executable, one could simply decompile the project or use an ILcode editor. If you mean as a solution in visual studios, using the solution explorer you can access "My Project" and simply double click that to get a nice little gui for adjusting your project.
EDIT:
For an overload of information about data in visual studios, you can visit: http://msdn.microsoft.com/en-us/library/wzabh8c4.aspx
For more information about just the data source window, you can visit:
http://msdn.microsoft.com/en-us/library/6ckyxa83.aspx
Aha! There is a way to add data access to a project that lacks it, per: http://msdn.microsoft.com/en-us/library/bb907587.aspx. To quote:
To create a class from a database table
If you are working with a Web site project, and the project does not already have an App_Code folder, in Solution Explorer, right-click the project, click Add ASP.NET Folder, and then click App_Code.
In Solution Explorer, right-click the App_Code folder (for a Web site project) or the project (for a Web application project) and then click Add New Item.
Under Installed templates, select Linq to SQL Classes template, type a name for the .dbml file, and then click Add.
-- The Object Relational Designer window is displayed. [Note that this is the window that Shift-Alt-D displays]
In Server Explorer, drag the database tables or other objects (such as views) that you want to use with LINQ to SQL into the Object Relational Designer window.
-- The tables and their columns are represented as a entities in the designer window.
Save the .dbml file.
This creates .designer.cs or .designer.vb file that is located under the .dbml file. The file contains a class that represents the database and a class that represents the table. The parameterless constructor for the database class reads the connection string from the Web.config file.
(Note that, after performing this procedure you may get a message "The type or namespace name 'Linq' does not exist in the namespace 'System.Data'". The solution to this problem is found here.)

XML File Changes using Installshield2011

I am developing an add-on installer using Installshield 2011 and project type is Basic MSI. I got a requirement where i need to update app.config file; the mentioned app.config is not part of current installer; app.config will be available by installing the base product. And on top of this my add-on installer will update the app.config file.
I am using XML File Changes feature provided by Installshield, i have configured it in the following steps:
Import the updated app.config file under XML File changes view.
Create a new element and assign key and value to it.
Repeated 1 and 2 and added 7 to 8 new entries as per the requirement
During testing i am seeing that the app.config file has been updated but entries are in single line instead of one below the other. I cannot enable "Format XML after changes" because one of the service which is referenced to app.config is not working and when i revoke the option services runs perfectly.
Is there any workaround/option to tell/ask installshield insert xml tag one below the other not in sinlge line using XML File Changes?
Thanks,
Chetan
If XML Changes isn't formatting the document in a way that's acceptable, you could consider using the Text File Changes which is just a simpler search and replace without understanding the schema of XML. Otherwise options are to check out Windows Installer XML ( you can use the XmlConfig elements found in the Util extension in a merge module and then use that merge module in InstallShield ) or to just write your own custom actions.

Custom SharePoint List View - can I put it in a feature (WSP)?

Here's my situation:
I'm working in SharePoint 2007 Enterprise, I have a feature that creates a list for me when I deploy and activate it. My usual workflow thus far has been to deploy the solution, activate it, then open up SharePoint Designer to customize the list.
My customizations are typically pretty complex, but I'll keep things simple. In this case, let's just say that I edit AllItems.aspx, convert the data view to an XSLT data view, then I add one column with static text.
I've used a few different tools (SPSource, VSeWSS, SharePoint Manager, OCDExportList, etc) to extract my custom schema.xml and all the default views, but I have yet to have any luck figuring out where the the code for AllItems.aspx is now that it's been customized.
When I extract (using any of the tools above) AllItems.aspx is no different than the default. The <View> element in schema.xml is reduced to one line, for example:
<View DefaultView="TRUE"
MobileView="TRUE"
MobileDefaultView="TRUE"
Type="HTML"
FPModified="TRUE"
DisplayName="All Documents"
Url="Forms/AllItems.aspx"
Level="1"
ContentTypeID="0x" />
I'm really stuck here... I've got no clue what to do. Is it even possible? It would save me a great amount of time (and documentation) if I could include my customizations in my feature.
If there's any other info I'm missing that would help, let me know... thanks!
Latest findings:
I've found out a bit more in the past couple hours. If I save the list as a List Template, then save the .stp file locally as a .cab file I can extract its contents. One of the files is manifest.xml which contains the schema.xml as well as a few other sections.
One of those sections is a <webparts> section that has a <webpart> for each view. Each of those <webpart> elements contains a really long string of characters... no clue what those characters actually represent.
The important thing is that I think any custom views have to actually be Web Parts if deployed as part of a solution... but I'm not positive.
I have faced a similar issue a while ago. I had to create a very customized view and I had to give up the ListFormWebPart completely, and have created my own webpart to render the data.
Generally, when you customize the aspx file in SPDesigner, all your changes will be in the aspx file itself. Open it in SPDesigner and you will see there all the changes you have made. After you have converted to the XSL Data View, the standard ListFormWebPart is replaced by a DataFormWebPart, which doesn't care about the <View> tags specified in the schema.xml; Look in the aspx file itself for the ListFormWebPart.
Why not do all the customizations you want on a list, save the list as a template (it will include the associated AllItems.aspx) and then use that template in your feature to create your list? You could add the extracolumn from code (if it's dynamic and cannot be included in the template), and so on.
Yes you can. Get the Sharepoint manager tool from Codeplex
http://spm.codeplex.com/
Install it on a machine in your farm, it will allow you to browse the farm via a tree view that shows all objects.
Make the list via the Sharepoint GUI, then browse to it w/ SPM.
SPM will allow you to extract the MOSS/WSS created xml that describes the list view (it shows up in the left hand property grid), which you can then plop into your manifest.xml
I have a similar issue and have been doing a lot of research into this. The dataview web part to me is one of the most powerful components in Sharepoint. Unfortunately I have to provide my solution as a .wsp package and that means that I can not just make the site and use Designer on that site. I have taken a 2 step approach in that I used designer to create my dataview and I also edited the code of that dataview to replace the ListID and Guids to ListName and the actual list name. This allows it to be exported and used in any page/site as long as the list name is the same. I am creating a webpart page document library also in my solution and I believe I can add the pages that have the webparts to this library using the onet.xml file. I will try to get the results of that test in as soon as I can do it.

Resources