EF Designer Code Generation Templates


When you create a model using the Entity Framework Designer your classes and derived context are automatically generated for you. In addition to the default code generation we also provide a number of templates that can be used to customize the code that gets generated. These templates are provided as T4 Text Templates, allowing you to customize the templates if needed.

The code that gets generated by default depends on which version of Visual Studio you create your model in:

  • Models created in Visual Studio 2012 & 2013 will generate simple POCO entity classes and a context that derives from the simplified DbContext.
  • Models created in Visual Studio 2010 will generate entity classes that derive from EntityObject and a context that derives from ObjectContext.
    Note: In Visual Studio 2010 we recommend switching to the DbContext Generator template once you’ve added your model.

This page covers the available templates and then provides instructions for adding a template to your model.

Read more of this post