Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6957307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:59:03+00:00 2026-05-27T14:59:03+00:00

What is a valid reason for using the ‘ADO.NET EntityObject Generator’ with EF? In

  • 0

What is a valid reason for using the ‘ADO.NET EntityObject Generator’ with EF? In case you don’t know, it generates a T4 file that does the building of the entities from the edmx. You can then change the T4 file to change how the entities are generated.

My question is: other than changing the base class in which entities are derived (also implementing interfaces) and changing the accessibility of entities and/or the context objects and naming conventions, what use does this have? Considering the existing features of EF and partial classes.

I’ve come up with 2

  1. Grab the table/column descriptions from the database and populate the summary on the entities and properties
  2. Generate light wieght DTO’s and do auto mapping.

1 seems like too much work considering it only updates the comments on the models, not the edmx itself (although it could do so)

2 Is this even useful?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T14:59:04+00:00Added an answer on May 27, 2026 at 2:59 pm

    We have done a few things with the T4 templates. The first one is to split out the generated code into one class per file, instead of one massive file. This just makes it easier to navigate and browse through the entities.

    The second, and more important one, is to automatically generate data annotation validation attributes such as StringLength and Required. This lets us validate our entities with a single function call, and it makes sure that their validation attributes are always in sync with the database (since if we change a column length in the DB, for example, the generated StringLength() attribute is then updated when we do ‘Update model from database’).

    At a previous job, we also added base classes and interfaces to the entities, as you mentioned in your question.


    Here’s a snippet from our T4 template that checks for required columns and string lengths and adds the necessary validation attributes:

        ''' <summary>
        ''' <#=SummaryComment(primitiveProperty)#>
        ''' </summary><#=LongDescriptionCommentElement(primitiveProperty, 1)#>
        <EdmScalarPropertyAttribute(EntityKeyProperty:=<#=code.CreateLiteral(ef.IsKey(primitiveProperty))#>, IsNullable:=<#=code.CreateLiteral(ef.IsNullable(primitiveProperty))#>)>
        <DataMemberAttribute()>
    <#+
      ' begin required attribute
      If Not ef.IsNullable(primitiveProperty) and not ef.IsKey(primitiveProperty) then
    #>
    <#+
        If ef.ClrType(primitiveProperty.TypeUsage) = GetType(Guid) Then
    #>
        <GuidRequiredAttribute(ErrorMessage:="<#=FixName(code.Escape(primitiveProperty))#> is required")>
    <#+
        Else
    #>
        <RequiredAttribute(ErrorMessage:="<#=FixName(code.Escape(primitiveProperty))#> is required")>
    <#+
        End If
    #>
    <#+
      End If
        If HasMaxLength(primitiveProperty.TypeUsage) then
        Dim d = MaxLength(primitiveProperty.TypeUsage)
    #>
        <StringLengthAttribute(<#=d#>, ErrorMessage:="<#=FixName(code.Escape(primitiveProperty))#> cannot be longer than <#=d#> characters")>
    <#+
        End If
    #>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My question may not make sense but I have valid reason. We use .net
I'm using File.createTempFile to create regular files I want to keep, the reason I
Create a file called Valid[File].txt and stick some text in it. Start powershell and
Hi guys for some weird reason I'm unable to send email using zend mail
I am using this IP Validation Function that I came across while browsing, it
I know that private inheritance is supported in C++ and only public inheritance is
We are using boost::filesystem in our application. I have a 'full' path that is
The below Unit Test fails, and I am looking for a valid reason for
I've been using PostgreSQL a little bit lately, and one of the things that
I'm using the jQuery Validate plugin on my demo page and for some reason

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.