0

I'm using EF 4.3.1 and "EF 4.x DbContext Generator for C#" for creating POCO using T4.

the classes generated are:

namespace MyProjects.Models
{
    public partial class ReCategory
...

Why the class is PARTIAL?

POCO are not classes without the plumbing of EF?

If you think this question is not appropriate please comment I will remove it, thanks for your time.

GibboK
  • 71,848
  • 143
  • 435
  • 658

1 Answers1

4

Why shouldn't they be? Just about every code generator these days will generate partial classes, so that you can add your own members to the class - in a separate file.

If these classes have to be regenerated, the file they are in will be completely replaced - but your customizations will survive.


Partial Class Definitions:

There are several situations when splitting a class definition is desirable:

  • When working with automatically generated source, code can be added to the class without having to recreate the source file. Visual Studio uses this approach when creating Windows Forms, Web Service wrapper code, and so on. You can create code that uses these classes without having to edit the file created by Visual Studio.
Community
  • 1
  • 1
Damien_The_Unbeliever
  • 234,701
  • 27
  • 340
  • 448
  • OK thanks, In case I would like to add data Notation (for validation) attribute, I should extend with another partial class the classes generated my the t4 correct? – GibboK Jun 26 '12 at 06:59
  • Yes, if you want to add an attribute, that's a good example of a customization that you can apply – Damien_The_Unbeliever Jun 26 '12 at 07:01