title: Using XSD.exe to generate non-nillable field with minOccurs = 1 for reference type
body: <p>I have the following class:</p>
  
  <pre><code>[Serializable]
  [XmlType(TypeName = "CoreAccount")]
  public abstract class Account
  {
      [XmlElement(IsNullable = true)]
      public string AccountNumber { get; set; }
      public decimal Balance { get; set; }
      public DateTime OpenDate { get; set; }
  }
  </code></pre>
  
  <p>I am using Microsoft's XSD.exe to generate a XML schema from the class. The 'AccountNumber' property is being generated in the XSD as follows:</p>
  
  <pre><code>&lt;xs:element minOccurs="1" maxOccurs="1" name="AccountNumber" type="xs:string" /&gt;
  </code></pre>
  
  <p>I am happy that this element is required but I do <b>not</b> want to accept an empty (nillable) value.</p>
  
  <p>I know that the easy option is to manually update the XSD to include:</p>
  
  <pre><code>nillable="false"
  </code></pre>
  
  <p>But I want to be able to do this programmatically so the XSD.exe tool will generate this. Does anybody have any suggestions? I have read elsewhere that this is a limitation of .NET but am wondering if anybody else has any ideas.</p>
  
  <p>Thanks in advance</p>