简体   繁体   English

Visual Studio随机更新我的dbml的designer.cs文件

[英]visual studio randomly updates designer.cs file for my dbml

I have a linq-to-sql connection for my database. 我的数据库有一个linq-to-sql连接。 I added a new table to the db in SQL server management studio today. 我今天在SQL Server Management Studio中的数据库中添加了一个新表。 Since it doesn't get automatically added in the dbml file, I dragged and dropped the table from server explorer as visual studio suggests. 由于它不会自动添加到dbml文件中,因此我按照Visual Studio的建议从服务器资源管理器中拖放了该表。

This automatically makes the necessary changes to its designer.cs file, which is good. 这会自动对其designer.cs文件进行必要的更改,这很好。

Unfortunately, it also makes some other changes I didn't ask for. 不幸的是,它也做出了其他我没有要求的更改。 There are a bunch of variables getting renamed in the designer file consistently, which has nothing to do with the table I'm adding or the one it's connected to! 在设计器文件中有一堆变量被一致地重命名,这与我要添加的表或它所连接的表无关!

I am being very careful not to move any other table in that layout- I'm just doing a drag 'n drop in an empty area. 我非常小心,不要在该布局中移动任何其他表格-我只是在空白区域进行拖放操作。 I tried this multiple times with the same result, so maybe I'm doing something wrong. 我多次尝试以相同的结果,所以也许我做错了。 I searched everywhere and I can't seem to find a better way to update the dbml file for tables added ( I found a bunch of questions about updating the dbml file when columns are added to existing tables, unfortunately those answers don't apply here). 我到处搜索,似乎找不到更好的方法来为添加更新dbml文件(当将列添加到现有表时,我发现了一堆有关更新dbml文件的问题,不幸的是,这些答案不适用于此处)。

Has anyone ran into this issue before? 有人遇到过这个问题吗? Is there any solution to this? 有什么解决办法吗?

The solution is to ignore it. 解决方案是忽略它。 The entire purpose of designer files is that they are tool-generated and may be regenerated at any time, for any reason, with any number of changes. 设计器文件的全部目的是使它们由工具生成,并且可以随时出于任何原因在进行任何数量的更改后重新生成。

Under no circumstances should you modify them, and there's usually not much of a reason to look at them. 在任何情况下都不应修改它们,通常没有太多理由来查看它们。

I had to fix it the hard way- manually updating the variable names by looking at the diff of the designer file. 我不得不用困难的方式来解决它-通过查看设计器文件的差异来手动更新变量名。 It was not fun, but it got rid of all the errors. 这不是很有趣,但是它消除了所有错误。

Apparently, it was renaming a bunch of associations for some other table consistently. 显然,它一直在为其他表重命名一堆关联。 Turns out someone had renamed those associations in the designer file instead of the .dbml file. 原来有人在设计器文件而不是.dbml文件中重命名了这些关联。 So every time any change is made to the .dbml file, the designer file recompiles, and old names come back! 因此,每次对.dbml文件进行任何更改时,设计器文件都会重新编译,而旧名称又回来了! I should probably update those associations in the dbml file so we don't have this problem in future. 我可能应该更新dbml文件中的那些关联,以便将来不再出现此问题。

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

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