views:

595

answers:

4

I used the LINQ to SQL designer in Visual Studio to create an object model of a database. Now, I want to add XML comments to each generated property but I can't figure out how to do it without erasing the properties the next time the dbml file is refreshed.

How can this be done?

A: 

Although I have no idea how to use this, but this looks like something that may be handy for you: http://msdn.microsoft.com/en-us/library/system.xml.linq.xcomment(VS.95).aspx

Vaibhav
That refers to a comment within an XML document, not XML documentation comments in code
bdukes
A: 

I believe it's not possible to keep xml comments in sync with autogenerated code automatically. However, xml comments can leave in separate file (just set "XML documentation file" option on "Project properties"->"Build" tab). You can create initial version of XML documentation file and update in manually if necessary

aku
+1  A: 

Depending on the source of your comments, I have an add-in that may be useful for you.

One of the features in the add-in updates the generated classes with xml comments and "Description" attributes containing the table and field descriptions from SQL Server's extended properties (and optionally also a summary of what indexes exist on the table and what indexes cover specific columns). In other words, if your database contains table and column descriptions you can get your L2S classes and their properties documented with the same descriptions.

Described in a bit more detail here: http://blog.huagati.com/res/index.php/2008/09/02/tools-part-5-add-ins-documentation-features-in-entity-framework-vs-linq-to-sql/

...and you can get a trial version of the add-in here: http://www.huagati.com/dbmltools/

KristoferA - Huagati.com
A: 

This tool can do it: http://www.huagati.com/dbmltools/