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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:38:10+00:00 2026-06-14T02:38:10+00:00

I have been playing with MVC 4 Web API with EF Code First 5.

  • 0

I have been playing with MVC 4 Web API with EF Code First 5. I have these POCOs:

public class Vehicle
{
    public int Id { get; set; }
    public int VehicleMakeId { get; set; }
    public int Model { get; set; }
    public int Year { get; set; }
    public int FuelType { get; set; }
    public int NoOfSeats { get; set; }   
    public virtual VehicleMake VehicleMake { get; set; }
}    

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

And a web API controller call: ‘http://localhost:63779/api/’vehicles and a GET that looks like:

public IEnumerable<Vehicle> Get()
{
   return Uow.Vehicles.GetAll().OrderBy(v => v.VehicleMake.Description);
}

I can return JSON results to the browser:

{
   id: 1,
   vehicleMakeId: 1,
   model: 1,
   year: 2004,
   fuelType: 2,
   noOfSeats: 1,
   vehicleMake: null
}

Notice vehicleMake is null. However, when stepping through the code the object does have the correct values.

Is it possible to see the JSON response for the object? Is it even desirable in I guess what is a lookup property?

I realise there is quite a bit of code missing here but hope there is enough for someone to give an explanation of what’s going on here. If not I can post more info.

Thanks

  • 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-14T02:38:12+00:00Added an answer on June 14, 2026 at 2:38 am

    Your VehicleMake is lazy loaded. When you look on it with the debugger it is loaded immediatley, so you need to include it in the query:

    public IEnumerable<Vehicle> Get()
    {
       return Uow.Vehicles.GetAll().Include(v => v.VehicleMake)
               .OrderBy(v => v.VehicleMake.Description);
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First post time, I've been playing around with MVC abit... I have a view
I have been playing around with the youtube API and node.js, so far I
I have been playing with generics and was hoping I could get some feedback
I have been playing around with some debugging and wrote some C code that
I have been playing around with MVC-Mini-Profiler, and found it very useful. However, on
I have been studying, playing with and working with ASP.NET MVC since Preview 1
I have been playing around with MVC 3 and looking at populating dropdownlists. I
I have been playing around with this preference activity code for most of the
I have been playing around with the code found here . I'm getting things
i have been playing around with MVC. I am currently stumped on with html

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.