views:

156

answers:

1

I would like to find a fast way to convert a Data Contract to a Entity Data Model.

Consider the following Data Contract:

[DataContract]
class PigeonHouse
{
    [DataMember]
    public string housename;
    [DataMember]
    public List<Pigeon> pigeons;
}

[DataContract]
class Pigeon
{
    [DataMember]
    public string name;
    [DataMember]
    public int numberOfWings;
    [DataMember]
    public int age;
}

Is there an easy way to automatically create an ADO.NET Entity Data Model from this code?

+1  A: 

No - because the data contract doesn't necessarily correspond 1:1 to a database table or an EDM entity.

What you could try to look into is something like code generation using T4 templates - read the data contract type, reflect over its properties, and generate a database table from it, or just an EDM entity (which could then be turned into a database table).

But I'm not aware of anything that does this out of the box.

marc_s