none
Problem in auto generated classes using VS2008 RRS feed

  • Question

  • Hello,
    Since I'm new to the concepts of linq to sql, I'm getting confused. After creating a "Linq to Sql Classes" item in an Asp.net web application, I Drag&Drop my needed tables from Server Explorer into the design surface, the tables are shown graphically there with their relationships.
    What I expect is that VS create a .CS file for each of my entities and I can see the code for each entity and their properties and a DataContext class, but what I get is only a .dbml file containing a .dbml.layout file and a .designer.cs file.
    So there is no class created for any of my entities, when I right-click on any of the classes in the design surface and choose "View Code", VS creates and opens a .cs file with same name as the .dbml file that I've created before, and there is a class in it named after my table in DB, but without any properties in it, It's an empty class!

    Am I expecting too much from VS or anyone know what's happening?!
    Thanks in advance
    Friday, July 10, 2009 7:13 PM

All replies

  • The classes created are in the .designer.cs file.

    When you do "view code" it creates a partial class that extends the one it has already created in the .designer.cs so you can add your code in the new one and it will maintain the .designer.cs (so don't modify that one, it will be overwritten).

    [)amien
    • Marked as answer by Damien GuardModerator Saturday, July 11, 2009 2:21 AM
    • Unmarked as answer by Ashki Saturday, July 11, 2009 10:59 AM
    Saturday, July 11, 2009 2:21 AM
    Moderator
  • Thanks for your reply Damien,
    But unfortunately the .designer.cs file is also empty, not even a line of code in it.
    Any idea what's happening here?

    Actually there is no class corresponding to my entity in the DB created for me here.
    Saturday, July 11, 2009 5:04 AM
  • I assume you are not getting any errors or warnings?

    Did you ever get a warning about packages could not be loaded on a prior launch of Visual Studio?  You could try opening the Visual Studio Command Prompt from the Start Menu and typing devenv /resetskippkgs to see if that re-activates the designer.

    If that doesn't work can you please send me your .dbml file to damiengu@microsoft.com to see if I it is something unusual in your schema?

    Thanks,

    [)amien
    Saturday, July 11, 2009 9:25 PM
    Moderator
  • I'm sorry Damien,
    I haven't seen the generated error previously, when I add the Linq to Sql Classes item it generates the following error:

    "Error    22    Could not load type 'System.Data.Linq.SqlClient.Sql2008Provider' from assembly 'System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'."

    I've searched for a solution and found a topic about it in this forum that you've participated in it, but that didn't help. Any suggestions?
    Sunday, July 12, 2009 2:58 PM
  • Hi,
    I hope I understand your question. I have found something like this, hope this will help:
    http://social.msdn.microsoft.com/Forums/en-US/linqtosql/thread/0c0f77a6-d712-43d2-a990-555df7960123/

    I have smilar problem. When I drag and drop table/stored proc it is seen on design mode but designer.cs file is not updated so there is no class or function created. I am using Linq to Sql in Asp.Net project. Therefore, there is no .csproj file to modify.

    I am stuck...
    Monday, July 13, 2009 9:00 AM
  • Ashki - try building the web site to ensure that the Custom Tool is run to generate/update the designer.cs file.  It should run when you save the dbml file - or right-click the dbml file and Run Custom Tool.  If you just drag'n'drop the table but don't save the dbml file, nothing changes except the in-memory version of the dbml file.  Saving the file should run the tool, updating the designer.cs file, then VS2008 should compile in the background.
    Toby
    Monday, July 13, 2009 5:07 PM
  • Thank you keskinTr, my case is a little different since I get an error from VS.

    Toby thanks for your reply, I've saved the dbml file before but nothing happens, and the project doesn't build because of the error I've posted in my previous post here. I think my VS is not working right.
    Tuesday, July 14, 2009 5:59 AM