首页 > 解决方案 > 我想从实体框架中检索所有客户端,但它返回 0 尽管我在表中有记录

问题描述

我的问题如下:

在 ApplicationDbContext 中我有一个 DbSet 客户端,在 dbo 表中我有 5 条记录。当我尝试进行一些 linQ 查询时,尽管我有 5 条记录,但它检索到 0 条记录。我想我在课堂上错过了一些 IEnumerable 吗?

    public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
    public DbSet<Carer> Carers { get; set; }
    public DbSet<Appointment> Appointments { get; set; }
    public DbSet<Client> Clients { get; set; }
}


    public class Client
{
    [Key]
    public int IdClient { get; set; }
    public string FullName { get; set; }
    public string FullAdress { get; set; }
    public string PostCode { get; set; }
    public string PhoneNumber { get; set; }

}



    var xx = _Context.Clients; // this returns 0 records

标签: entity-frameworklinq

解决方案


推荐阅读