导致“O/R Designer 验证失败”的原因使用 Designer 对 .dbml 文件进行细微更改后?
我使用 SQL Server Management Studio 在表中添加了一些列,然后想在 Visual Studio 2010 的项目中引用它们,其中使用实体框架加载,这似乎没有一个方便的功能来简单地从数据库导入更新。
所以我手动添加了列。它们只是像现有列一样的位列,因此我使用剪切和粘贴来复制该列,然后重命名它们并填充存储字段以匹配。
但是当尝试构建项目时,它会失败并显示:
O/R Designer validating failed 。 。 。 myDB.dbml 错误:操作无法完成。未指定的错误
我发现的关于这些不是很有帮助的错误消息的主要提示涉及重新启动 Visual Studio。这对我没有帮助。
还有什么可能导致(以及什么可以修复)此错误?
I added some columns to a table using SQL Server Management Studio, and then wanted to reference them in my project in Visual Studio 2010, where it is loaded using Entity Frameworks, which seems not to have a handy feature for simply importing updates from the database.
So I manually added the columns. They were just bit columns like an existing column, so I used cut and paste to duplicate that column, then renamed them and filled in the Storage field to match.
But then when trying to build the project, it would fail with:
O/R Designer validation failed . . . myDB.dbml Error: The operation could not be completed. Unspecified error
The main tips I found about these not-very-helpful error messages, involved restarting Visual Studio. That didn't help me here.
What else can cause (and what can fix) this error?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在我的例子中,造成这种情况的原因是 Visual Studio 2010 的可视化 DBML 编辑器中的一个明显错误!
也就是说,我添加并正确手动输入的新列没有正确保存。即使关闭 Visual Studio 并重新加载编辑器,这在某种程度上也是不可见的 - 在那里,它显示正确。
然而,当我使用 Notepad++ 查看实际的 .dbml 文件时,我可以看到 Storage= 值仍然与我的 Cut & 列相同。粘贴自我手动输入的正确值,而不是在可视化 DBML 编辑器中显示的值!
我注意到正确的列甚至没有 Storage= 字段,这可能是编辑器中错误所在的线索。
我使用 Notepad++ 从 .dbml 文件中删除了不正确的 Storage= 字段,这解决了构建问题。
我还需要进入可视化设计器并进行随机的微小更改(我轻推了显示中表格的位置),然后它会将我添加的列的成员变量添加到自动生成的 LINQ .cs 文件中。
What caused this in my case, was an apparent bug in Visual Studio 2010's visual DBML editor!
That is, the new columns I had added and manually entered correctly, did not get saved correctly. This was somehow invisible even when closing Visual Studio and reloading the editor - there, it appeared correctly.
However, when I looked at the actual .dbml file using Notepad++, I could see that the Storage= values were all still the same as the column I had Cut & Paste from, rather than the correct values I had hand-entered, and that showed in the visual DBML editor!
I notice that the correct columns do not even have a Storage= field, which is probably a clue to what the bug in the editor is.
I deleted the incorrect Storage= fields from the .dbml file using Notepad++, and this solved the build problem.
I also needed to go into the visual designer and just make a random trivial change (I nudged the position of the table in the display) before it would add member variables for the columns I had added, to the auto-generated LINQ .cs file.