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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:27:58+00:00 2026-06-07T16:27:58+00:00

I need to have a CRUd operations on my class (CompetenceSpecific). Competence has three

  • 0

I need to have a CRUd operations on my class (CompetenceSpecific).
Competence has three derived classes – CompetenceFunction, CompetenceArea and CompetenceSpecifc

The error I recieved: 
  There are no EntitySets defined for the specified entity type 'CompetencyManagement.Domain.Entities.CompetenceFunction'. If 'CompetencyManagement.Domain.Entities.CompetenceFunction' is a derived type, use the base type instead. Parameter name: TEntity

How should I correct this? Please suggest a solution that would solve my problem. Thanks

Please check the code below, I removed some parts of the code for simplicity.

–MODEL

public class Competence
{
    public int CompetenceID { get; set; }
    public int CourseID { get; set; }
...
}

public class CompetenceFunction : Competence
{

}

–REPOSITORY and interfaces

public interface IRepository<T> where T : class
{
    T GetById(object id);
    IEnumerable<T> GetAll();
    IEnumerable<T> Query(Expression<Func<T, bool>> filter);
    void Add(T entity);
    void Remove(T entity);
}

public abstract class Repository<T> : IRepository<T>
    where T : class
{
    protected IObjectSet<T> _objectSet;

    public Repository(ObjectContext context)
    {
        _objectSet = context.CreateObjectSet<T>();
    }
...
}


public class CompetenceFunctionRepository : Repository<CompetenceFunction>
{
    public CompetenceFunctionRepository(ObjectContext context)
        : base(context)
    {
    }

    public override CompetenceFunction GetById(object id)
    {
        return _objectSet.SingleOrDefault(s => s.CompetenceID == (int)id);
    }
}

–UNIT oF WORK

public interface IUnitOfWork
{
    IRepository<CompetenceFunction> CompetenceFunctions { get; }
    IRepository<CompetenceArea> CompetenceAreas { get; }
    IRepository<CompetenceSpecific> CompetenceSpecifics { get; }
    void Commit();
}

public class UnitOfWork : IUnitOfWork, IDisposable
{
    private CompetenceFunctionRepository _competencefunction;
    private CompetenceAreaRepository _competencearea;
    private CompetenceSpecificRepository _competencespecifc;

    public UnitOfWork(ObjectContext context)
    {
        if (context == null)
        {
            throw new ArgumentNullException("Context was not supplied");
        }

        _context = context;
    }

    #region IUnitOfWork Members


    public IRepository<CompetenceFunction> CompetenceFunctions
    {
        get
        {
            if (_competencefunction == null)
            {
                _competencefunction = new CompetenceFunctionRepository(_context);
            }

            return _competencefunction;
        }
    }

    public IRepository<CompetenceArea> CompetenceAreas
    {
        get
        {
            if (_competencearea == null)
            {
                _competencearea = new CompetenceAreaRepository(_context);
            }

            return _competencearea;
        }
    }

    public IRepository<CompetenceSpecific> CompetenceSpecifics
    {
        get
        {
            if (_competencespecifc == null)
            {
                _competencespecifc = new CompetenceSpecificRepository(_context);
            }

            return _competencespecifc;
        }
    }

–Im getting an error in this part of Repository

public Repository(ObjectContext context)
    {
        _objectSet = context.CreateObjectSet<T>();
    }


  There are no EntitySets defined for the specified entity type 'CompetencyManagement.Domain.Entities.CompetenceFunction'. If 'CompetencyManagement.Domain.Entities.CompetenceFunction' is a derived type, use the base type instead. Parameter name: TEntity

Here’s how I implement in the controller

 private IUnitOfWork _unitOfWork;
 var a = _unitOfWork.CompetenceFunctions.GetAll();
 return View(a);
  • 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-07T16:28:00+00:00Added an answer on June 7, 2026 at 4:28 pm

    You have to get derived type by the OfType function, e.g.

    context.CreateObjectSet<Competence>().OfType<CompetenceFunction>()
    

    In your case that would mean that there is only a CompetenceRepository that serves all derivatives of Competence.


    Edit

    (After your comment)
    First, UoW is meant for temporarily storing changes that should be dealt with in one batch (like changes to be committed to the database). GetAll and similar functions are repository stuff.

    But do you need repositories? I like this post. When beginning to know EF, I would focus on the ins and outs of EF without getting distracted too much by surrounding architecture. E.g. start with services that at the inside communicate directly with the context and expose methods like GetCompetenceFunctions, GetCompetenceAreas (using OfType), and SaveCompetenceFunction, ….

    You can address these service methods directly from action methods in the MVC controllers.

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

Sidebar

Related Questions

I have a (REST) application that handles CRUD operations initiated by a 3rd party,
I am unit testing some CRUD operations. My questions are: 1) If I need
I have need to produce LINE, BAR, and PIE charts in Rails. I have
I have need to return multiple results from a subquery and have been unable
I have need to pack four signed bytes into 32-bit integral type. this is
I have need for a function pointer that takes two arguments and returns a
I have need for AutoCompliteTextView in PreferenceActivity so I extended DialogPreference. My auto-complite is
I need to have custom checkboxes which wasn't that tricky. I made checkbox_selector to
We need to have a good way to encrypt our C source. We need
I need to have a list of links generated by JSF and displayed in

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.