实体框架DbSet包含0条记录

实体框架DbSet包含0条记录

问题描述:

所以我有以下问题:

我有一些Vehicle实体,它对应于数据库中的一个表。但是,当我尝试使用以下行来检索所有记录时:

I have some Vehicle entity that corresponds to a table in the DB. But when I try to retrieve ALL the records with the following line :

var vehicles = db.VehicleSet.ToList();

作为结果,我得到了零对象……而数据库中的表大约为0。 18k条记录。

I get ZERO objects as result ... whilst the table in the DB has approx. 18k records.

任何想法可能出在哪里,或者问题太模糊了?

Any idea where the problem might be, or is the question too vague?

我知道了。原来这是数据库的问题。在我的结构中,我使用的是 Discriminator字段,该字段未设置并且会导致问题。

I Figured it out. Turns out it was a problem with the Database. In my structure I was using a "Discriminator" field which was not set and was causing problems.

谢谢您的时间。