Entity Framework trying to retrieve non existent c

2019-04-24 03:06发布

问题:

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?

回答1:

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.