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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:08:30+00:00 2026-06-11T19:08:30+00:00

I have been on a project with entity framework in DDD pattern. I don’t

  • 0

I have been on a project with entity framework in DDD pattern. I don’t use the default custom tool for the entity and I have a repository and some model classes.

I have 3 tables in my entity framework:

  1. Category
  2. CategoryContent
  3. Content

Category with categoryContent and content with categoryContent have 1 to many relationship. (I don’t use many to many here because I have some properties in CategoryContent table)

When I send a request for the list of CategoryContent and show content.Title of this list in MVC I have seen this error:

Unable to set field/property CategoryContents on entity type System.Data.Entity.DynamicProxies.Content_731FEFC3E064D6098DC133918117C2359E2F308D2EB1E5D8D986538641AAB7CD.

But when I traced, the program doesn’t have any problems and returned data and show.

I use the message system (request and response message in the service project).

this code is a method for return list of contentcategory.

 public IEnumerable<CategoryContent> GetContents(int categoryID)
    {
        Query query = new Query();
        OrderByClause order = new OrderByClause();
        order.PropertyName = "ID";
        order.Desc = true;
        query.OrderByProperty = order;
        query.Add(new Criterion("CategoryID", categoryID, CriteriaOperator.Equal));

        return  categoryContentRepository.FindBy(query);
    }

categoryContentRepository is an object from CategoryContentRepository class in Repository project for management work with DB.

in MVC Controllers:

public ActionResult Content(int id)
    {
        var contentService = ServiceFactory.CreatContentService();
        var response = contentService.GetContents(id).ToList();

        return PartialView("_Content", response);
    }

in view (_content.cshtml):

@model List<Plus.Model.CategoryContent>

@foreach (var item in Model)
{
    @Html.ActionLink(item.Content.Title, "Amir")
}

Model Classes:

public class Category: ValidationBase, IAggregateRoot
{
    public int ID { get; set; }

    [NotNullOrEmpty()]
    public string Name { get; set; }

    [NotNullOrEmpty()]
    public int Ordering { get; set; }

    public int? ParentID { get; set; }
public Guid ModifiedBy { get; set; }
public DateTime ModifiedOn { get; set; }
public string ModifiedReason { get; set; }
public bool Deleted { get; set; }
public bool Active { get; set; }

    
    public virtual Category Parent { get; set; }
    public virtual IList<Category> Childeren { get; set; }
    public virtual IList<CategoryContent> CategoryContents { get; set; }
}

public class CategoryContent : ModelBase, IAggregateRoot
{
    public int ID { get; set; }
    public int ContentID { get; set; }
    public int CategoryID { get; set; }

    public virtual Content Content { get; set; }
    public virtual Category Category { get; set; }
}

public class Content: ModelBase, IAggregateRoot
{
    public int ID { get; set; }
    public string Title { get; set; }
    public string Intro { get; set; }
    public int? ParentID { get; set; }
    public bool IsSeries { get; set; }
    public byte LikeVoteStatus { get; set; }

    public virtual IList<SubContent> SubContents { get; set; }
    public virtual Content Parent { get; set; }
    public virtual IList<Content> Childeren { get; set; }
    public virtual CategoryContent CategoryContents { get; set; }
}
  • 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-11T19:08:31+00:00Added an answer on June 11, 2026 at 7:08 pm

    Code of content model has a bug:

    public virtual CategoryContent CategoryContents { get; set; }
    

    and right code is:

    public virtual IList<CategoryContent> CategoryContents { get; set; }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have been working on a project using Entity Framework 5 in development
I have been using Entity Framework CTP with Code-First as in this tutorial by
We have some code that uses Entity Framework against a DB2 database. When we
I am trying to pre-generate view metadata for my Entity Framework project and have
I am converting a project from another ORM to Entity Framework. I have a
I have a question with regards to automapping entity framework objects which have been
We have an Entity Framework project with several models set up using .NET 4
I have recently been learning MVC3 using Entity Framework 4.3 and Dependancy Injection so
I'm trying to use LINQPad with my MVC3 project that is using Entity Framework
We been having some discussions on approaches to using the entity framework at work

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.