LINQ to SQL templates updated, now on CodePlex
- 📅
- 📝 193 words
- 🕙 1 minute
- 📦 .NET
- 🏷️ LINQ, T4
- 💬 12 responses
My templates that allow you to customize the LINQ to SQL code-generation process (normally performed by SQLMetal/LINQ to SQL classes designer) have been updated once again.
Updates
- Now licensed under the Microsoft Public License and hosted at CodePlex
- User options specified with a
var options
block at the start of the template - Option for each class to be a separate file that is reflected in the VS project
EntityPerFile=true
- Detection and support of IsComposable functions
- General code clean-up and better error handling such as missing DBML file
CodePlex
CodePlex makes it easier for people to be able to see and merge updates in with their own modified versions as well as report issues via the issue tracker etc. There is also an RSS feed that lets you keep track of releases, source updates or whatever else you are interested in.
For now it is a grab-the-source style release but I hope to publish downloadable tested releases wrapped up in a Visual Studio Installer (VSI) package to make getting started easier soon. Feel free to grab the sources directly via TFS/Subversion to be able to diff them with your own modified versions.
Enjoy!
[)amien
12 responses to LINQ to SQL templates updated, now on CodePlex
Hi,
Excuse me sir … where is the .wmv file? I’m trying to build an MetaData file automatically having as a start point my .dbml LINQ to SQL DataContext File.
Carlos Porras (El Salvador)
Hi Damien,
When using the built-in generator the namespace of my DataContext is MyCompany.Database (the .dbml is located in the folder ‘Database’ within the project). But with using the template, the namespace ‘Database’ is missing. Any ideas?
Harro
@Daniel : This is normally caused by a DBML coming from another project. The DBML tends to reference the connection via the app.config but the app.config wasn’t copied. Opening the DBML in the designer will detect this and remove the offending code so you can setup a new connection.
Great tool! It’s really nice to be able to customize the L2S code like that. I used it to fix a circular reference problem LINQ was having when serializing a parent entity to JSON (by adding ScriptIgnore above any Associations).
On another note, the line base(global::.Default., mappingSource) was causing a build error for me (couldn’t find Default). Is this just because I’m using VS2010b2?
Daniel
Hi, what if I have columns like ‘private’ and ‘operator’ in my database table. Compiling the code generated with this template fails, obviously. I can’t (or lets say don’t want to) make any changes to my tables… Any ideas?
Thanks, Pavel.
@Nigel: The warnings I see are:
Love the reorganised code but not so taken by the CA warnings I get from the code that gets generated.
How do I surpress any code warnings from the generated code. The project is marked to ignore such but both standard VS2008 and running with this template causes CA to shout out warnings.
Regards, Nigel
This is a fantastic piece of plumbing and will save my team a lot of work, specifically in the realm of serialization. I really appreciate your efforts, Damien. I really hope DataContract serialization support is native in the next version of Visual Studio LINQ to SQL.
When I try it I get…
Also, how do I remove it? I took out the “L2ST4.ttinclude” “VOC3_DB.tt” files but now get the following Warning…
The custom tool ‘MSLinqToSQLGenerator’ failed while processing the file ‘Data_Layer\VOC3_DB.dbml’.
Thank you.
@Melle you’ll need to install either the Clarius or the Tangible T4 editors as there is no syntax highlighting in-the-box.
Brilliant!
I will make it to work on separate assemblies. One for the entities and one for the data access. This looks really great. Thanks for the effort!!
How do you get the syntaxt highlighting on the .TT source (without VS complaining about whitespace and identifiers — I set it as a C# file)?
Regards,
Melle
viewing plug-in with moonlight for linux. works well.