Create separate class file for each complex entity in an xsd file.

Jul 5, 2011 at 8:00 AM


I am currently building an integration project using WCF and would like to automate the process of building all the entities that are used within the service contracts.

Currently, the business domain model is divided into sets of related entities, with each set of entities represented by an xsd file to be provided to the client along with WSDL's for the services.

For any given xsd we are endeavoring to automatically generate several separate entity classes, one for each entity represented in the xsd file. Can this done with Xsd2Code?


The generated files are to be extended with related partial classes which implement any required custom behaviors.

Because the generated classes form the basis of a data contract this means that all the classes have to be annotated with [DataContract] and [DataMember] as required. 

Can these annotations be generated automatically and formatted as shown below? 


using System.Runtime.Serialization;


 [DataContract(Name = "EntityName",  Namespace = "http://schemas.companyname/.../Integration/Entities")]

public class EntityName { ... }


[DataMember(Order = 1, IsRequired = true, Name = "EntityDescription")]       

public string EntityDescription{ get; set; }