Search code examples
visual-studio-2010linq-to-sqlbuild-errordbml

What causes "O/R Designer validation failed" after minor changes to a .dbml file using Designer?


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?


Solution

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