我写了一个Efproductrepository
并抛出错误:
System.InvalidOperationException:'实体类型ProductMethod不是当前上下文模型的一部分。'
这是我的代码中引发错误的部分:
public class EFProductRepository : IProductRepository
{
private readonly OnlineshoppingStoreEntities1 context = new
OnlineshoppingStoreEntities1();
public IEnumerable<ProductMethod> GetProduct()
{
return context.Products.Select(c => new ProductMethod
{
Category = c.Category,
Description = c.Description,
Name = c.Name,
Price = c.Price,
}).AsEnumerable();
}
}
我该如何解决?谢谢