Reputation: 5524
I'm using Reverse Engineered Code First code and see stubs like:
public class User
{
public User()
{
this.Addresses = new List<Address>();
...
}
public int ID { get; set; }
...
}
When, based on this question, i'd expect to see partial classes.
Wouldn't this change the preferred way of extending the generated classes with my own code (which is very nicely summarized in the linked answer, btw)?
thx
Upvotes: 0
Views: 394
Reputation: 2090
Our aim was to generate the simplest classes possible, as close to what you would write by hand as we could. There is no problem changing them to be partial - that's exactly the kind of reason we made the generation customizable.
~Rowan
Upvotes: 2
Reputation: 10416
There is a way to customize the output of the entity objects by changing the TT files.
Rowan Miller has an excellent blog post on how to do it.
In your example, you can update the Entity.TT file that's int he template
From this:
public class <#= efHost.EntityType.Name #>
To this:
public partial class <#= efHost.EntityType.Name #>
and it will create the partial classes you're looking for.
Upvotes: 2