实体框架试图检索不存在的列 [英] Entity Framework trying to retrieve non existent column
问题描述
我试图从数据库中检索的VideoCollection项目,但得到 {无效的列名称USER_ID'。}
- 当我设置一个断点,我可以看到,EF试图选择user_id列,但它不在Cs对象或数据库模式存在。 (它确实存在于另一个表但这不应该的问题)。反正是有调试为什么发生这种情况?
I'm trying to retrieve the VideoCollection items from the database, but getting {"Invalid column name 'User_Id'."}
- when I set a breakpoint I can see that the EF is trying to select User_Id column but it doesn't exist in the Cs object or the database schema. (It does exist in another table but that shouldn't matter). Is there anyway to debug why this is happening?
推荐答案
你有一个具有一个VideoCollection引用的用户类?如果是这样,你可能需要明确界定两者之间的关系。由于它是,它看起来像EF被推断说VideoCollection应该包含一个外键, USER_ID
定义的关系。
Do you have a User class that has a reference to a VideoCollection? If so, you probably need to explicitly define the relationship between the two. As it is, it looks like EF is inferring that the VideoCollection should contain a foreign key, User_Id
that defines the relationship.
这篇关于实体框架试图检索不存在的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!