after a lot of help yesterday, I encountered a known bug in asp.net4 beta - I upgraded to VS2012 RC Express (4.5), and now I get an internal server error, and I canโt see why. I am creating a web API:
Model
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.ComponentModel.DataAnnotations; using System.Data.Entity.ModelConfiguration.Conventions; using System.Data.Entity; using System.ComponentModel.DataAnnotations.Schema; namespace MvcApplication6.Models { public class tblCustomerBooking { [Key()] public int customer_id { get; set; } public string customer_name { get; set; } public string customer_email { get; set; } public virtual ICollection<tblRental> tblRentals { get; set; } } public class tblRental { [Key()] public int rental_id { get; set; } public int room_id { get; set; } public DateTime check_in { get; set; } public DateTime check_out { get; set; } public decimal room_cost { get; set; } public int customer_id { get; set; } [ForeignKey("customer_id")] public virtual tblCustomerBooking tblCustomerBooking { get; set; } } }
Then I used the Add Controller wizard, selecting "Template: API controller with read / write instructions using the Entity Framework", selected tblCustomerBooking as my model class and clicked that:
using System.Data.Entity; namespace MvcApplication6.Models { public class BookingsContext : DbContext { public BookingsContext() : base("name=BookingsContext") { } public DbSet<tblCustomerBooking> tblCustomerBookings { get; set; } } }
My controller (BookingsController.cs), automatically created by Visual Studio 2012 Express, is:
using System; using System.Collections.Generic; using System.Data; using System.Data.Entity.Infrastructure; using System.Linq; using System.Net; using System.Net.Http; using System.Web; using System.Web.Http; using MvcApplication6.Models; namespace MvcApplication6.Controllers { public class BookingsController : ApiController { private BookingsContext db = new BookingsContext();
I added a breakpoint in "return db ....." above and checked the Watch element in VS - it clearly shows the object, with the client and the associated rents:

However, if I allow the script to continue, I just get the http500 error (as shown below in Fiddler): 
Is there more code that I can add to the controller so that I can understand why this is an error? Or can anyone understand what might be wrong? It seems that VS is returning it in order, as shown in the first screenshot, but it seems it cannot send it.
Thanks for any help or pointers,
Mark
Update
Hi, I'm just asking too much about the API? Is it not possible (out of the box) to simply return objects with one or more relationships? Can he really create only one list of objects?
Thanks Mark