如何消除 Visual Studio 对重新创建 DBML 的 .designer.cs 文件的痴迷?
这让我抓狂。我认为这是因为应用程序中的某些连接字符串不匹配(使用 MVC),但 Visual Studio 不断获取我的 .designer.cs 文件并重新创建它,在末尾添加一个“1”(或者 2,如果它之前已经这样做了,呃! )。我的问题有两个:有没有办法阻止 VS 这样做?但更重要的是:我如何手动将其设置回原来的 .designer.cs 或者这是不可能的?我尝试删除它创建的新文件(因为我不断收到重复定义构建错误),并且它不会自动与解决方案资源管理器中的 DBML 文件结构中的原始文件关联起来。
有谁能解决这种疯狂的问题吗?
This is driving me nuts. I think it is because of some connection string mismatching across the app (using MVC) but Visual Studio constantly takes my .designer.cs file and recreates it adding a '1' at the end (or 2 if it already did this before argh!). My question is two-fold: Is there a way to stop VS from doing this? But more importantly: How can I manually set it back to the original .designer.cs or is that not possible? I try to delete the new one it created (because I keep getting duplicate definition build errors) and it won't automatically associate back with the original one in the DBML file structure in solution explorer.
Does anyone have a solution for this madness?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这不是一个理想的解决方案,但可以采用以下解决方法。在 Visual Studio 中,进入 .dbml 文件的属性并清除
Custom Tool
属性。这将阻止它针对 DBML 运行自动生成器并创建设计器文件。当然,对 DBML 的进一步更改不会反映在设计器文件中。至于为什么它会生成多个设计器文件,这很奇怪。要手动将一个文件关联到另一个文件下,您需要修改项目文件。查找类似的行
并将其更改为
Not an ideal solution, but a workaround would be the following. In Visual Studio, go into the properties of the .dbml file and clear out the
Custom Tool
property. This will prevent it from running the auto-generator against the DBML and creating the designer files. Of course further changes to the DBML won't be reflected in the designer file.As for why it's generating multiple designer files, that's an oddity. To manually associate a file under another, you need to modify the project file. Look for a line like
and change it to