Model view controller EF 4:上下文调用不返回任何记录

Model view controller EF 4:上下文调用不返回任何记录,model-view-controller,frameworks,entity,Model View Controller,Frameworks,Entity,我有一个简单的MVC项目,以产品为模型。我首先使用EF4.0.2代码。 我的存储库是: public class EFProductRepository : IProdcutRepository { private EFDBcontext context = new EFDBcontext(); public List<Product> Products { get { return conte

我有一个简单的MVC项目,以产品为模型。我首先使用EF4.0.2代码。 我的存储库是:

  public class EFProductRepository : IProdcutRepository
  {
    private EFDBcontext context = new EFDBcontext();

    public List<Product> Products
    {
        get
        {
            return context.Products.ToList();
        }

        set
        {
            context.SaveChanges();
        }
    }
}

但是它返回零条记录,而我有5条记录

您确定Products表中有记录吗?如果复制/粘贴并对数据库运行SELECT查询,是否在结果集中看到记录?是,它返回5个记录。此外,如果查询指向所需的数据库,探查器会显示查询已被连接字符串删除。可能查询是针对另一个具有空表的数据库运行的。(作为旁注:这是我见过的最奇怪的属性设置者。)设置者只是一个占位符:)
SELECT 
[Extent1].[ProductID] AS [ProductID], 
[Extent1].[Name] AS [Name], 
[Extent1].[Description] AS [Description], 
[Extent1].[Price] AS [Price], 
[Extent1].[Category] AS [Category]
FROM [dbo].[Products] AS [Extent1]