I am creating a class library containing several datasets that are generated from client xml files.
I drag example xml files into VStudio and create .xsd file, add them to the project and sets tool to MSDataSetGenerator and then (after getting the first build error) found out that all the generated classes are called NewDataSet. I avoid build errors by setting tool namespace in the properties dialog of the xsd file. But application code that consumes multiple datasets becomes ugly because you can't use "using" without "NewDataSet" becoming ambiguous. Besides, the class name "NewDataSet" is not really useful.
Is there any way to override/affect the naming of the generated class?
I have seen this and resolved it like this:
add this to your schema tag ... "xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
So for example the first two lines of your xsd might look like:
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
Your xsd likely wraps everything in an element, whose name is what you're intending the class name to be... so do this:
<xs:element name="YOUR_CLASSNAME" msdata:IsDataSet="true">
That's roughly what I did to make it work.
You can change the name of the generate class by setting the id attribute of the schema element.

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With