Linq to SQL 创建重复的设计器文件
我的 Linq to SQL DBML 文件有一个奇怪的错误,每当我保存它时,都会创建一个重复的文件,而不是保存到现有的设计器文件。
这会导致各处错误,因为 file.designer.cs 和 file1.designer.cs 内部的数据上下文构造函数之间存在歧义。
有没有办法修复此错误,而不涉及删除和重新创建 dmbl 文件。因为这个错误发生在我的所有 DBML 文件上,其中一些文件相当大。
上图显示了我遇到的问题。
I have a strange bug with my Linq to SQL DBML files, when ever I save it, instead of saving to the existing designer file a duplicate file is created.
This is causing errors all over the place as there is ambiguity between the data context constructor inside of file.designer.cs and file1.designer.cs
Is there any way to fix this error that doesnt involve deleting and recreating the dmbl files. as this error is happening on all of my DBML files some of which are rather large.
The above image shows the issue that I'm having.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不确定是什么导致了这种情况(但 Marc 关于文件只读或未检出的建议似乎是可能的),但 .proj 文件中描述了关联。如果您使用文本编辑器打开该文件,您应该会看到类似以下内容的位置:
将
Minerva1.designer.cs
替换为Minerva.designer.cs
。现在,您可以从项目中删除或排除Minerva1.designer.cs
文件,下次调用生成器时,它将按预期覆盖Minerva.designer.cs
。Not sure what could have caused this (but Marc's suggestion about the file being readonly or not checked out seems possible), but the association is described in the .proj file. If you open that file with a text editor you should see somewhere within something like:
Replace
Minerva1.designer.cs
withMinerva.designer.cs
. You can now delete or exclude theMinerva1.designer.cs
file from you project and the next time the generator is invoked it will overwriteMinerva.designer.cs
as expected.我有同样的问题。事实证明版本控制正在保存该文件。构建过程无法重新创建该文件,因此会创建一个新文件。由于该文件是自动生成的,因此可以安全地从版本控制中删除。我正在使用 git 进行版本控制。
I had the same issue. It turns out version control was holding the file. The build process cannot recreate the file so it creates a new one. Since this file is automatically generated, it is safe to remove from the version control. I am using git for my version control.