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 7623353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:41:09+00:00 2026-05-31T04:41:09+00:00

I have a edmx file being set its Code Generation Strategy to None and

  • 0

I have a edmx file being set its Code Generation Strategy to None and a T4 template set to it, where I removed the Factory Method Creation logic. I have introduced some additional method for few of the entities on a separate file through partial class.

Ex: I have introduced few methods for the entity User on partial class and I derived the classes Admin and Person from User where I want to introduce some other methods.

The issue I’m facing here is, while assigning a value to the navigation property of Admin, it throws the exception Object mapping could not be found for Type with identity 'CivilRegistry.ControlledModel.Admin'.

User Class:

public partial class User
{

    protected static UserRepository repository = new UserRepository();

    public User Insert(User user)
    {
        user.AddedDate = DateTime.Now;
        user.AddedUserId = this.UserId;
        return repository.Insert(user);
    }
    //
    //Other methods goes here.
    //
}

Admin Class:

public class Admin : User
{
    public Admin() { }

    private Admin(User user)
    {
        this.UserName = user.UserName;
        //
        //Other properties
        //
        this.AddedUser = user.AddedUser; //This line throws, Exception.
    }

    public static Admin FindBy(int id)
    {
        //repository.FindByID returns an instance of User entity.
        return new Admin(repository.FindByID(user => user.UserId == id && user.RoleId == (int)RoleEnum.Admin));
    }
}

How can I resolve this?

  • 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-31T04:41:10+00:00Added an answer on May 31, 2026 at 4:41 am

    It is not supported. You cannot define entity in EDMX and then derive additional classes from the entity in your code. Derived classes created this way are not entities any more and cannot be retrieved or persisted by EF because EF doesn’t know how to map them anymore.

    The reason why it fails in assigning navigation property is that EF knows that Admin is User and it tries to attach it to the context but it doesn’t find the Admin type in mapping (EDMX).

    The solution is mapping the inheritance = moving your inheritance to EDMX where you will define User entity and derived Person and Admin entities. Here you have some tutorial.

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

Sidebar

Related Questions

i have an entity-model file (edmx) file which contains few tables and few stored
I have mapped the database in the edmx file from the database. Now how
I have in my web application an ADO.NET Entity-Framework *.edmx file. When I browse
I have a .edmx file and I can't open it with the designer. It
I have the following tables represented in my Entity Framework diagram (.edmx file) Users
I have an edmx file that I generated using edmgen2, I am using the
I have an edmx file and I changed a table in my database. I
Suppose I have two table tab1, tab2. EF will create a edmx file and
I have an edmx file that reflects 100% my DB schema. Along with this
I have created the POCO class and it's equivalent in edmx file (Category entity

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.