简体   繁体   中英

visual studio randomly updates designer.cs file for my dbml

I have a linq-to-sql connection for my database. I added a new table to the db in SQL server management studio today. Since it doesn't get automatically added in the dbml file, I dragged and dropped the table from server explorer as visual studio suggests.

This automatically makes the necessary changes to its designer.cs file, which is good.

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).

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. So every time any change is made to the .dbml file, the designer file recompiles, and old names come back! I should probably update those associations in the dbml file so we don't have this problem in future.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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