C# – Adding stored procedure to DBML doesn’t generate *.designer.cs code

asp.netclinq-to-sqlvisual-studio-2008

I'm trying to add a new stored procedure to my Asp.Net website with Visual Studio 2008, the way I did some time ago, but this doesn't generate any code in the *.designer.cs and when I try to call the SP, I just get a undefined/not-found error.

Here is what I have done so far :

  1. make sure I have read/write access to MyApp.dbml, MyApp.dbml.layout and MyApp.designer.css
  2. Open the DBML (in "graphic" mode)
  3. Refresh the list of SPs in the server explorer
  4. Drag and Drop the targeted SP onto the DBML
  5. Save it
  6. Build the website

The XML inside the DBML is created with the correct types for each column of the result, but absolutely nothing is created in the designer.cs.

  • I checked, and no "new" designer.cs is created like it did for this person.
  • I tried using "Run custom tool" (as suggested here) with and without deleting the MyApp.designer.cs, and it never did anything

Does anybody know were the problem might come from? Am I missing something?

Best Answer

As nothing else seemed to work, I used Pleun's idea, which worked like a charm:

  1. create a new empty Asp.Net Web site with a whole new DBML
  2. import my SPs into this new DBML
  3. copy generated code from the new empty project to my old one (theses portions of code are easy to spot as they are the only ones mention my SPs)
    1. XML in the MyApp.dbml
    2. Csharp in the MyApp.designer.cs (the method that calls the SP + the partial class with accessors for the result of the SP)
  4. build my "old" project

In fact, I had to close and reopen VS for that to work completely.

Related Topic