简体   繁体   中英

Entity Framework 4: Invalid Column Name

I know there are a lot of questions like this asked, but I can't seem to find one that fits my scenario. I'm using Entity Framework, Database First (my database already existed when I decided to start using EF). I'm creating my edmx file, loading the correct tables into my model. However, I keep getting an "Invalid Column Name" error when I try to perform a query for a specific table through Entity Framework.

Using SQL Server Profiler, I see that the query is syntactically correct (I can run the query myself through SQL Server Management Studio), so I have no idea why this could be happening.

Any ideas? Thanks in advance.

EDIT: This isn't a SQL Exception, it's a System.Data.EntityCommandExecutionException

What happened to me, in the past, is that I had a database locally with the column, and then, after testing the application the connection string was pointing to another database in which the new column was absent.

Is that the case?

You can always check if the connection you are using (when playing the app) is the same as the one you are generating your edmx file to make sure.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM