none
DataContext file and methods not generating VS 2010 RRS feed

  • Question

  • Hi All,

    I am new to LinQ To SQL. I am using VS 2010Premium. I am trying to create a sample Linq To SQL project. This is i implemented.

    1. Createa DB in my local SQLExpress with 4 tables. All have Primary keys.

    2. Created a window application project in VB.NET

    3. Added new Item LinqToSQL (.dbml) in the project.

    4. Connected the sqlexpress through server explorer. Dragged the tables into DBML designer.

    5. Complied the code.

    It ddnt generate any class file (I expect one class for each table and a DataContext file as per the tutorials.

    Please help if i am doing anything wrong. By the way my OS is Windows 7 & SQL Server 2008.

    Thanks

    Ratheesh


    Thanks Ratheesh
    Tuesday, February 22, 2011 10:19 PM

Answers

  • Hi RatheeshC,

     

    If you are confident you added the tables correctly. Just click on the table and right click view code. This will generate a partial class that allows you to enter some custom code for your data context.

    If you go to the top of solution explorer you can click an icon labelled "Show All Files". Click it, then expand out the files under the DBML.

     

    Go to your designer class and have a look at the generated code. Hopefully you will find a class with a name that matches your table.

     

    Otherwise you can delete the contents of the file and then in the solution explorer, right-click on the dbml file and click "Run Custom Tool". This will regenerate the classes.

     

    In a large project we sometimes needed to right-click the dbml file and click "Exclude from Project" (it will recursively exclude the children files automatically). Then right-click the dbml and click "Include in Project".

     

    Finally I highly recommend a tool called SQL Metal Builder to generate the dbml file. You can download it here: http://sourceforge.net/projects/sqlmetalbuilder/


    Allan Merolla | BEng, JD, MCP | .NET/Sharepoint | My Blog at http://www.parallelfun.com/
    Wednesday, February 23, 2011 3:08 AM

All replies

  • Hi RatheeshC,

     

    If you are confident you added the tables correctly. Just click on the table and right click view code. This will generate a partial class that allows you to enter some custom code for your data context.

    If you go to the top of solution explorer you can click an icon labelled "Show All Files". Click it, then expand out the files under the DBML.

     

    Go to your designer class and have a look at the generated code. Hopefully you will find a class with a name that matches your table.

     

    Otherwise you can delete the contents of the file and then in the solution explorer, right-click on the dbml file and click "Run Custom Tool". This will regenerate the classes.

     

    In a large project we sometimes needed to right-click the dbml file and click "Exclude from Project" (it will recursively exclude the children files automatically). Then right-click the dbml and click "Include in Project".

     

    Finally I highly recommend a tool called SQL Metal Builder to generate the dbml file. You can download it here: http://sourceforge.net/projects/sqlmetalbuilder/


    Allan Merolla | BEng, JD, MCP | .NET/Sharepoint | My Blog at http://www.parallelfun.com/
    Wednesday, February 23, 2011 3:08 AM
  • Hi Ratheesh,

    I am writing to check the status of the issue on your side.  Would you mind letting us know the result of the suggestions? 
     
    If you need further assistance, please feel free to let me know.   I will be more than happy to be of assistance.

    Have a nice day.


    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, March 2, 2011 2:00 AM
    Moderator