views:

41

answers:

1

Hello

I've been using enity framework that came with 3.5sp. And now I've redone things for enityframework 4 and asp.net mvc 2. I've come across something (which worked in my previous version and asp.net mvc 1.0).

I have this:

public IQueryable<Booking> GetBookings()
{

   return from b in _entities.Bookings.Include("BookingObject")
          select b;
}

And in my controller I have:

return View("Index", new BookingsViewModel
        {
            Bookings = _br.GetBookings().ByDay(DateTime.Today)
        });

And it doesnt seem to include the "BookingObject"-entity, so I can type like <%= Model.Bookings.BookingObject.BookingObjectName %> in my view.

What might be missing here? Do I need to turn something on in the diagram for it to include entities or?

/M

+1  A: 

No, it should work exactly as before. I'm assuming you have a navigation property BookingObject on your Booking item - but then the .Include() would error out if you didn't. I don't think there's anything else you need to set up, or at least not that isn't done by default. I'd verify the definition of the navigation property in the .edmx editor at least.

You're definitely using the final RTM EF4 code? We hit a bug in the final RC building incorrect SQL and returning no results for one specific include sequence, but it was a lot more complex than that.

Failing that I would use SQL Server Profiler to trace out the SQL it's using and try and debug that.

Rup