MVC not returning data
Posted by: Mark Willis
Date: November 28, 2012 07:15AM

Just started revisiting MVC and am going through the apress book "Pro ASP.NET MVC 2 Framework" before looking at MVC 4. I decided to try the SportStore example using MySQL instead of SQLServer and Entity Framework instead of LINQ to SQL. Everything is code first, so have entities;
[Table("Products")]
public class Product
{
public int ProductID { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public decimal Price { get; set; }
public string Category { get; set; }
}
and a repository like;
public class SqlProductsRepository : IProductsRepository
{
private EFDbContext context = new EFDbContext();
public IQueryable<Entities.Product> Products
{
get { return context.Products; }
}
}
with a context like;
public class EFDbContext : DbContext
{
public DbSet<Product> Products { get; set; }
}
Using DI I can replace the SQL repository with a fake one and get data, but using the Sql repository then I get nothing.
The products table in MySQL was created independently and populated with some data. I've written a console app and used EF to generate the model and code and that retrieves the data perfectly. I'd hoped I might be able to see what the difference between the console app and the MVC app was but the code first and model generation code seem to be too disimiliar to be of use other than proving C# can be used to get data from MySQL.
I'm stumped now where to go to debug this. Any help appreciated.

Options: ReplyQuote


Subject
Written By
Posted
MVC not returning data
November 28, 2012 07:15AM
November 29, 2012 03:41AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.