实体框架DbSet包含0条记录 [英] Entity Framework DbSet contains 0 records

查看:71
本文介绍了实体框架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.

谢谢您的时间。

这篇关于实体框架DbSet包含0条记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆