Alwyn
Alwyn

Reputation: 8337

Information hiding with EF generated entities

Can I make EF to generate entity classes with private property setters?

Eg. I want something like

public class MyTable
{
    public Guid Id {get; private set;}
    //... And so on and so forth, basically the class should hide the setters
}

Upvotes: 1

Views: 137

Answers (1)

daryal
daryal

Reputation: 14919

Assuming that you are using tt templates to generate POCO entities, by modifying the tt file it is possible.

On the otherhand, since private variables will not be serialized during WCF communication, you will face with problems if you are using any service - client architecture and exchanging generated entities.

Upvotes: 1

Related Questions