简体   繁体   English

实体框架4:无效的列名称

[英]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). 我正在使用Entity Framework,Database First(当我决定开始使用EF时,我的数据库已经存在)。 I'm creating my edmx file, loading the correct tables into my model. 我正在创建我的edmx文件,将正确的表加载到我的模型中。 However, I keep getting an "Invalid Column Name" error when I try to perform a query for a specific table through Entity Framework. 但是,当我尝试通过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. 使用SQL Server Profiler,我发现查询在语法上是正确的(我可以通过SQL Server Management Studio自己运行查询),所以我不知道为什么会发生这种情况。

Any ideas? 有任何想法吗? Thanks in advance. 提前致谢。

EDIT: This isn't a SQL Exception, it's a System.Data.EntityCommandExecutionException 编辑:这不是SQL异常,它是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. 您可以随时检查您正在使用的连接(在播放应用程序时)是否与生成edmx文件的连接相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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