Is there T4 templates available for generating c# classes from xsd?
+1
A:
Not that I know of, but take a look at LINQ to XSD (http://linqtoxsd.codeplex.com/). You can use LinqToXsd.exe to generate strongly typed classes based on your schema. And then you have full LINQ support as well. Very handy.
You could also set up a pre-build event on your project that looks something like:
"$(ProjectDir)Lib/LinqToXsd/LinqToXsd.Exe" "$(ProjectDir)MySchema.xsd" /fileName:MySchema.cs
And that would generate the classes from the schema right before you build, so if you change your schema, your classes will stay in sync with each build.
Samuel Meacham
2010-07-01 23:15:24
Nice, didn't know that. Much better than a pre build step.
Samuel Meacham
2010-07-01 23:39:21
You can also use the Build Action property of the XSD file in the Solution Explorer, and set it to LinqToXsdSchema (this requires that you set up the project to import LinqToXsd.targets)
Xavier Poinas
2010-07-01 23:41:02