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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T08:50:40+00:00 2026-05-21T08:50:40+00:00

I have the following models in my ASP.NET MVC 3 project: public class Task

  • 0

I have the following models in my ASP.NET MVC 3 project:

public class Task
{
    public int Id { get; set; }
    public DateTime CreatedOn { get; set; }
    public TaskStatus Status { get; set; }
}

public class TaskStatus
{
    public int Id { get; set; }
    public string Description { get; set; }
}

For reference, here is my DbContext class:

public class TaskManagerSets : DbContext
{
    public DbSet<Task> TaskSet { get; set; }
    public DbSet<TaskStatus> TaskStatusSet { get; set; }
}    

Then I have a List Action in my TaskController:

TaskManagerSets dbcontext = new TaskManagerSets();
public ActionResult List()
{
    var tasks = from tsk in dbcontext.TaskSet.Include("TaskStatusSet")
                select tsk;
    return View(tasks.ToList());
}

Finally I have the Task List View:

 @model IEnumerable<TaskManager.Models.Task>

 <ul>
 @foreach (var tsk in Model) 
 { 
    <li>@tsk.Id | @tsk.CreatedOn | @tsk.Status.Description</li> 
 } 
 </ul>

When I execute my project I get the following error:

A specified Include path is not valid. The EntityType ‘CodeFirstNamespace.Task’ does not declare a navigation property with the name ‘TaskStatus’.

The problem is definitely on the Include("TaskStatusSet") but how should I fix 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-21T08:50:40+00:00Added an answer on May 21, 2026 at 8:50 am

    Since you are working with the DbContext API the best option is to use the type-safe overload of Include:
    using System.Data.Entity;

    // You must add a using statement for this namespace to have the following 
    // lambda version of Include available
    
    //...
    
    var tasks = from tsk in dbcontext.TaskSet.Include(t => t.Status)
                select tsk;
    

    You will get Intellisense and compile-time checks which helps to avoid issues with wrong strings like you had.

    The less satisfactory, NON-type-safe technique would be:

    var tasks = from tsk in dbcontext.TaskSet.Include("Status")
                select tsk;
    

    Note: the presented order of the techniques has been changed, so keep this in mind when reading comments.

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

Sidebar

Related Questions

In an ASP.NET MVC application where I have the following model.. public class EventViewModel
If you have the following: Asp.Net MVC 2 project having object classes that define
Given the following setup, I have three assemblies. Web (ASP.NET MVC 3.0 RC1) Models
I have the following code in my ASP.NET MVC 3 project: <script src=@Url.Content(~/Scripts/jquery.validate.min.js) type=text/javascript></script>
i am using asp.net mvc 2 here i have a following class Applicant and
I have the following view in ASP.net MVC 3: @model Models.CreateProjectViewModel <script type=text/javascript src=@Url.Content(~/Scripts/jquery.validate.min.js)></script>
I have the following models set up: class Contact < ActiveRecord::Base belongs_to :band belongs_to
I'm building an ASP.Net MVC website. Rather than have everything in one project, I've
I am new to MVC and I have been following Steven Andersons Pro ASP.Net
In my ASP.NET MVC application, I have a project that contains all the business

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.