title: NDBUnit schema error
body: <p>I've been searching for an answer for quite some time without any luck.</p>
  
  <p>I'm using NDbUnit for my test data and I want to be able to generate my XSD files automatically. I don't want to have to regenerate my XSD files each time I add a new property to my classes. So my plan is to automatically generate the XSD files using the XsdDataContractExporter class since some of my classes contain IList and I got some errors using the xml serializer.</p>
  
  <p>this is the code I got so far:</p>
  
  <pre><code>XsdDataContractExporter exporter = new XsdDataContractExporter();
  exporter.Export(typeof(Supplier));
  
  //XmlQualifiedName xmlQualifiedName = exporter.GetRootElementName(typeof(Supplier));
  foreach (XmlSchema schema in exporter.Schemas.Schemas()) {
      XmlWriter writer = XmlWriter.Create(String.Format(@"..\..\data\{0}.xsd", GetSchemaName(schema)), new XmlWriterSettings() {
      ConformanceLevel = ConformanceLevel.Auto,
      Encoding = Encoding.UTF8,
      Indent = true,
      OmitXmlDeclaration = false
  });
  
  foreach (XmlSchemaObject include in schema.Includes) {
      XmlSchemaImport importedSchema = include as XmlSchemaImport;
      if (importedSchema != null) {
          ArrayList lst = new ArrayList(exporter.Schemas.Schemas(importedSchema.Namespace));
          XmlSchema actualImportedSchema = (XmlSchema)lst[0];
          importedSchema.Schema = actualImportedSchema;
          importedSchema.SchemaLocation = Path.GetFullPath(String.Format(@"..\..\data\{0}.xsd", GetSchemaName(actualImportedSchema)));
      }
  }
  schema.Write(writer);
  writer.Close();
  }
  DataSet ds = new DataSet();
  ds.ReadXmlSchema(@"..\..\data\business.model.supplier.xsd");
  </code></pre>
  
  <p>the problem is that I get an error when reading the schema which is:</p>
  
  <pre><code>failed: System.InvalidOperationException : Nested table 'SupplierCategory' which inherits its namespace cannot have multiple parent tables in different namespaces.
  </code></pre>
  
  <p>The bottom line is, I want to use a dynamically generated XSD file from a type to use with NDBUnit to populate my database with test data. Is this the right approach ? This is the schema that are generated and that gives my the error:</p>
  
  <p>Supplier:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;xs:schema xmlns:tns="http://schemas.datacontract.org/2004/07/Business.Model.Supplier" elementFormDefault="qualified" targetNamespace="http://schemas.datacontract.org/2004/07/Business.Model.Supplier" xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt;
    &lt;xs:import schemaLocation="C:\dev\skeleton\branches\dev\src\testconsole\data\business.model.supplier.category.xsd" namespace="http://schemas.datacontract.org/2004/07/Business.Model.Supplier.Category" /&gt;
    &lt;xs:import schemaLocation="C:\dev\skeleton\branches\dev\src\testconsole\data\arrays.xsd" namespace="http://schemas.microsoft.com/2003/10/Serialization/Arrays" /&gt;
    &lt;xs:complexType name="Supplier"&gt;
      &lt;xs:sequence&gt;
        &lt;xs:element minOccurs="0" name="Categories" nillable="true" xmlns:q1="http://schemas.datacontract.org/2004/07/Business.Model.Supplier.Category" type="q1:ArrayOfSupplierCategory" /&gt;
        &lt;xs:element minOccurs="0" name="Comments" nillable="true" xmlns:q2="http://schemas.microsoft.com/2003/10/Serialization/Arrays" type="q2:ArrayOfstring" /&gt;
        &lt;xs:element minOccurs="0" name="Description" nillable="true" type="xs:string" /&gt;
        &lt;xs:element minOccurs="0" name="Name" nillable="true" type="xs:string" /&gt;
      &lt;/xs:sequence&gt;
    &lt;/xs:complexType&gt;
    &lt;xs:element name="Supplier" nillable="true" type="tns:Supplier" /&gt;
  &lt;/xs:schema&gt;
  </code></pre>
  
  <p>SupplierCategory:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;xs:schema xmlns:tns="http://schemas.datacontract.org/2004/07/Business.Model.Supplier.Category" elementFormDefault="qualified" targetNamespace="http://schemas.datacontract.org/2004/07/Business.Model.Supplier.Category" xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt;
    &lt;xs:complexType name="ArrayOfSupplierCategory"&gt;
      &lt;xs:sequence&gt;
        &lt;xs:element minOccurs="0" maxOccurs="unbounded" name="SupplierCategory" nillable="true" type="tns:SupplierCategory" /&gt;
      &lt;/xs:sequence&gt;
    &lt;/xs:complexType&gt;
    &lt;xs:element name="ArrayOfSupplierCategory" nillable="true" type="tns:ArrayOfSupplierCategory" /&gt;
    &lt;xs:complexType name="SupplierCategory"&gt;
      &lt;xs:sequence&gt;
        &lt;xs:element minOccurs="0" name="Description" nillable="true" type="xs:string" /&gt;
      &lt;/xs:sequence&gt;
    &lt;/xs:complexType&gt;
    &lt;xs:element name="SupplierCategory" nillable="true" type="tns:SupplierCategory" /&gt;
  &lt;/xs:schema&gt;
  </code></pre>
  
  <p>Any advice would be great !
  Thx,
  Franck</p>