So let’s start to find the answer of - how can we connect a database with our c# project through entity framework?
In this example I am using the default database of Microsoft northwind.sdf.
1- At first open "add new item" dialog in project. Then select the ado.net entity data model(.edmx) option you can change the name of your data model as you like, here I am using the default name see in screen -1
3- In next screen select new connection option and then a screen with "Connection properties" will appear, now click on change button and select database option for - Microsoft sql server compact, then click on browse button and select your database (default northwind.sdf its located in your Microsoft sql server compact edition folder) then click on ok see in screen – 3
Screen - 3
4- The wizard is automatically creating the required connection string for your database, click on next button -
Screen - 4
5- In next screen the tables of selected database is shown. Check it and then click on finish button see in screen - 5
Screen - 5
Finally the entity diagram of the required database and the tables are shown.
Screen - 6
You can also view the "app.config" xml file to view the connection string of your application –
Screen - 7
Now u can play with database easily.
Please tune in to get further tutorials regarding advanced filtering in queries, optimizing queries etc...
No comments:
Post a Comment