我的 Web 应用程序中的列名称无效
我有紧急且无法解释的问题,因此我们将不胜感激。我有两个不同的数据库,它们完全相同,只是每个数据库都有不同的数据。
我有一个使用 LINQ-To-EF 的 Web 应用程序,在我更改连接字符串中的数据库之前,一切都工作正常。即使数据库完全相同,我也会收到错误:“列名‘tema_id’无效。”问题是“tema_id”在这两个数据库中都不存在,但是,不知何故它确实存在于 .edmx 文件中。映射的名称应该是“aktivnost_id”,而不是现在的“tema_id”。
我尝试从数据库更新模型,但在这种情况下,一切都会出错,并且错误列表中出现了数十个不同的错误。
我提供了有问题的表的映射详细信息的屏幕截图(您可以看到“tema_id”,它应该是“aktivnost_id”)。
我知道我的解释可能有点令人困惑,但如果需要任何其他信息,我会提供。
I have urgent and unexplainable problem so any help would be appreciated. I haave 2 different databases which are exactly the same except there is different data in each of them.
I have a web application using LINQ-To-EF and until I've changed the database in connection string everything was working fine. Even though the databases are exactly the same I receive the error: "Invalid column name 'tema_id'." The problem is that "tema_id" doesn't exist in any of those two databases, however, somehow it does exist in .edmx file. The name of the mapping should be "aktivnost_id" and not "tema_id" how it is now.
I've tried updating the model from the database, but in that case everything gets wrong and I get dozens of different errors in Error List.
I've provided the screenshot of mapping details for the problematic table (you can see "tema_id" which should be "aktivnost_id").
I know my explanation might be a bit confusing, but if any additional info is needed I will provide it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果没有您尝试更新时发生的错误的完整详细信息,我很难给出完整的答案;然而,我非常想将 EDMX 编辑为 XML,使用“find”来定位
tema_id
,然后直接修复。如果没有别的事,很快就可以尝试:)
It I hard to give a complete answer without the full details of the errors that occur when you try to update; however, I would be sorely tempted to edit the EDMX as XML, use "find" to locate
tema_id
, and fix directly.If nothing else, it is quick to try :)
您是否尝试过直接编辑 .EDMX 文件以匹配实际的表结构?
Have you tried to edit the .EDMX file directly to match the actual table structure?
尝试通过 edmgen.exe 在 Visual Studio 之外手动生成整个数据访问层,
对 EF4 使用以下命令(调整参数以反映您的数据库名称、用户名、密码)
@"%windir%\Microsoft.NET\Framework\ v4.0.30319\edmgen.exe" /mode:full Generation /c:"数据源=tcp:127.0.0.1;初始目录=your_database;用户ID=sa;密码=your_password;集成安全性=False;" /project:DataContext /entitycontainer:DataContext /namespace:Project /language:CSharp /pluralize
Try to generate whole data access layer manually outside of visual studio through edmgen.exe
use the following command for EF4 (adjust parameters to reflect your db name, username, password)
@"%windir%\Microsoft.NET\Framework\v4.0.30319\edmgen.exe" /mode:fullgeneration /c:"Data Source=tcp:127.0.0.1;Initial Catalog=your_database;User ID=sa;Password=your_password;Integrated Security=False;" /project:DataContext /entitycontainer:DataContext /namespace:Project /language:CSharp /pluralize