Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6886923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:49:13+00:00 2026-05-27T05:49:13+00:00

I am using XSD’s to define my DTO types in C#. I am using

  • 0

I am using XSD’s to define my DTO types in C#. I am using XSD.exe to gen the classes from the XSD’s.

I have a Common.xsd that defines an Address type and I want to use this in more than one class:

  <xs:complexType name="Address">
    <xs:sequence>
      <xs:element name="Street1" type="xs:string"/>
      <xs:element name="Street2" type="xs:string"/>
      <xs:element name="City" type="xs:string"/>
      <xs:element name="State" type="xs:string"/>
      <xs:element name="Zip" type="xs:string"/>
    </xs:sequence>
  </xs:complexType>

  <xs:element name="Address" type="mhm:Address"/>

I am referencing this in a company XSD:

  <xs:include schemaLocation=".\Common.xsd"/>
  <xs:complexType name="Company">
    <xs:sequence>
      <xs:element name="AdmCode" type="xs:string"/>
      <xs:element name="CompanyCode" type="xs:string"/>
      <xs:element name="Name" type="xs:string"/>
      <xs:element ref="mhm:Address"/>
    </xs:sequence>
  </xs:complexType>

  <xs:element name="Company" type="mhm:Company"/>

And an employee XSD:

  <xs:include schemaLocation=".\Common.xsd"/>
  <xs:complexType name="Employee">
    <xs:sequence>
      <xs:element name="EmployeeNumber" type="xs:int"/>
      <xs:element name="FirstName" type="xs:string"/>
      <xs:element name="LastName" type="xs:string"/>
      <xs:element name="Address" type="mhm:Address"/>
    </xs:sequence>
  </xs:complexType>
  <xs:element name="Employee" type="mhm:Employee"/>

I gen the classes using this command line:

xsd .\XSD\Common.xsd /c /o:. /n:"DomainModel"
xsd .\XSD\Employee.xsd /c /o:. /n:"DomainModel"
xsd .\XSD\Company.xsd /c /o:. /n:"DomainModel"

When I go to compile the project, I find that the Address type has been generated in both the Company.cs class file and the Employee.cs class file.

How can I get the Address type generated just once in the Common.cs class file and the Employee and Company types use this single Address type?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T05:49:14+00:00Added an answer on May 27, 2026 at 5:49 am

    You can use XSD.exe with multiple file arguments:

    xsd .\XSD\Common.xsd .\XSD\Employee.xsd .\XSD\Company.xsd /c /o:. /n:"DomainModel"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using xsd.exe to make the C# classes for our settings. I have a
I have this Maven task to generate Java classes from an XSD file using
I have generated an XSD file from an XML snippet using xsd.exe /out What
I have generated a set of classes using xsd.exe and created an XML document
I'm using XmlSerializer with classes created from a xsd using xsd.exe . It has
I've seen several questions regarding problems with generating classes from XML Schema using xsd.exe
I have a set of classes build using xsd.exe, and I am trying to
I generated some C# classes from an XSD using the Visual Studio XSD utility
I am trying to generate C# code from an XSD using xsd.exe Here is
I have created an XSD and have run XSD.exe on top of that .xsd

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.