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

  • Home
  • SEARCH
  • 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 8276493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:23:28+00:00 2026-06-08T08:23:28+00:00

I’m basically re-asking this question as the only and accepted answer is not an

  • 0

I’m basically re-asking this question as the only and accepted answer is not an answer to the question.

Is it possible to tell EF to use a class that subclasses EntityObject, like the one below, as the base class of generated entity classes?

public abstract class CustomEntityObject : EntityObject
{
    <additional functionality>
}

The reason I’m asking is I want to stop adding interfaces and implementing them on all entity types in separate partial class files. By sub-classing EntityObject I could implement the additional functionality once only.

Update:

EF implicitly uses a .tt file to generate entity classes. By implicitly I mean you don’t see the .tt file in your project. The solution is to add the template explictly (right-click on the .edmx designer and click “Add Code Generation Item…”, then add “ADO.NET EntityObject Generator”). You then change a single value in the .tt:

string BaseTypeName(EntityType entity, CodeGenerationTools code)
{
    return entity.BaseType == null ? "EntityObject" : MultiSchemaEscape((StructuralType)entity.BaseType, code);
}

changes to:

string BaseTypeName(EntityType entity, CodeGenerationTools code)
{
    return entity.BaseType == null ? "CustomEntityObject" : MultiSchemaEscape((StructuralType)entity.BaseType, code);
}
  • 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-06-08T08:23:30+00:00Added an answer on June 8, 2026 at 8:23 am

    Thing is, that using default T4 template designer will generate entity classes inherited from EntityClass.

    To use model designer and have ability to supply custom base class you need to download http://msdn.microsoft.com/en-us/library/ff477605.aspx (it’s a description how to use it, before it was in add item>online templates, but at least on my vs2012 can’t find it anymore, it tmay be that is gone for a reason) template and edit template files to inject your custom base class, but I think that most of programmers look at POCO for a reason, so may be better idea is to have classes that don’t have persistence attached.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I am doing a simple coin flipping experiment for class that involves flipping a
I need a function that will clean a strings' special characters. I do NOT
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
I know there's a lot of other questions out there that deal with this
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.