locked
Customize the code generation from EDMX file RRS feed

  • Question

  • EF 4.0

    Are there any examples of extending the generated code that produces the ObjectContext and EntityObjects from the EDMX file?

    Specifically, I would like all of the generated EntityObject classes to be derived from my own subclass of EntityObject, not the core .NET EntityObject.

    Friday, March 9, 2012 12:33 AM

Answers

  • To start working with ADO.NET EntityObject Generator template, open the .edmx file in the entity designer.

    Right-click the surface and select "Add Code Generation Item..."

    Select ADO.NET EntityObject Generator

    The .tt file will be added to your project. Open it in the editor and find the following line that defines the typed ObjectContext

    <#=Accessibility.ForType(container)#> partial class <#=code.Escape(container)#> : ObjectContext

     

    The following topic explains the ADO.NET EntityObject Generator template

    http://msdn.microsoft.com/en-us/library/ff477605.aspx

    Please, let me know if that does not answer your question.

    thank you,

    Julia


    This posting is provided "AS IS" with no warranties, and confers no rights.

    • Marked as answer by Allen_MSDN Tuesday, March 13, 2012 2:29 AM
    Friday, March 9, 2012 9:34 PM

All replies

  • Hi,

    If i am not wrong, you can change at using T4 template.

    You will find these templates at

    Microsoft Visual Studio 10.0\Common7\IDE\VCSExpress\ItemTemplatesCache\1033\...

    Hope this helps you. 


    If this post answers your question, please click "Mark As Answer". If this post is helpful please click "Mark as Helpful".

    Friday, March 9, 2012 5:30 AM
  • To start working with ADO.NET EntityObject Generator template, open the .edmx file in the entity designer.

    Right-click the surface and select "Add Code Generation Item..."

    Select ADO.NET EntityObject Generator

    The .tt file will be added to your project. Open it in the editor and find the following line that defines the typed ObjectContext

    <#=Accessibility.ForType(container)#> partial class <#=code.Escape(container)#> : ObjectContext

     

    The following topic explains the ADO.NET EntityObject Generator template

    http://msdn.microsoft.com/en-us/library/ff477605.aspx

    Please, let me know if that does not answer your question.

    thank you,

    Julia


    This posting is provided "AS IS" with no warranties, and confers no rights.

    • Marked as answer by Allen_MSDN Tuesday, March 13, 2012 2:29 AM
    Friday, March 9, 2012 9:34 PM