Asked By
sam hudson
1200 points
N/A
Posted on - 05/22/2011
Hello,
I am a learner in the software development sector, wanting to learn C# language. For this purpose, I use Microsoft Visual Studio 2008 software. Now I am starting a LINQ project. In this very project I need to create a dbml file. But I cannot find instructions on how to create it. I need a step by step instructions to create a dbml file and connect with my desired database. I use Microsoft SQL server 2005 edition for database server. Please help me to solve this problem.
Answered By
jakie
450 points
N/A
#101796
Adding Dbml file Software development
Hi Sam Hudson,
Welcome to software development works. There are many books to help with your problem. However, I will give you step by step instructions. First, you need to add a LINQ to SQL classes. For this you need to right click on your solution file, in solution explorer then add a new item. In the new default window, select data in left portion, in your visual studio 2008. Then select the LINQ to SQL class from the right portion of your new window. Create a dbml file.
Steps: Add > new item > LINQ to sql class > create.
Now you need to connect your particular database for your project to this file. For this, use server explorer. Add a connection to your server explorer. Then put your server name which should be as (…/sqlexpress). Now select SQL authentication. Put a user name and password. Select your database. Click test connection. Hopefully your connection will be succeed. Now just click ok and get your database connected.
You just need to drag the tables, views etc from your database to the dbml file. Your database will now show in server explorer. Just click on it and select your needed tables and views. It may seem hard after reading but doing these steps sequentially while reading is lot easier. Actually, practical work is far easier than it seems when reading. Hopefully, your problem will be resolved after following these steps. Thank you.
Adding Dbml file Software development
Hey,
I got a whole demo project for you to check out on how to create, attach and might debug issues with LINQ, it also has good references for some intermediate stuff.
LINQ to SQL, this project is complete learners ref with the demo projects files licensed for personal and community use.