ASP.NET 4.0 and the Entity Framework 4 - Part 5 - Using the GridView and the EntityDataSource
page 3 of 7
by Vince Varallo
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 34845/ 99

Step 2: Add an Entity Data Model

The next step is to create an entity modal using the new Entity Framework 4.  Once you have a modal you can then add EntityDataSource controls to you application that can dynamically query your database.

1.    Right click on the web site in the Solution Explorer and select Add New Item… from the pop-up menu.

2.    Select ADO.NET Entity Data Model from the list of templates.  Change the file name to AdventureWorksModel.edmx and click the Add button.  You'll get a message asking if you want to create an App_Code folder.

3.    Click Yes.  This will display the Entity Data Model Wizard.

4.    Choose Generate From Database and click the Next button.

5.    The next screen asks you to choose a data connection.  The drop down list will display any connections you have already setup in the Server Explorer.  If you haven't already created a connection to the AdventureWorks database then click the New Connection button.

6.    This displays the Connection Properties form.  Enter your server name, authentication information, and select the AdventureWorks database from the list of available databases.

7.    Click the Test Connection button to make sure you have entered the right information.  If you get an error fix the settings and try again.

8.    Once testing the connection is successful click the OK button.

9.    The AdventureWorks connection should appear in the list of connections and be selected.

10. Make sure the "Save entity connection settings in Web.Config as" checkbox is checked.

11. Click the Next button.

12. The next form in the wizard allows you to select which tables, views, or stored procedures you want to add to the model.  We're only going to be editing the Contact table so expand the Tables node and check the box next to the Contact table.

13. Click the Finish button.  Visual Studio will add the AdventureWorks entity data model to your web site.


View Entire Article

User Comments

Title: vb nvvbnvb   
Name: vbnvbn
Date: 2012-06-06 10:09:02 PM
Comment:
vbn
Title: Cant see images   
Name: jrk
Date: 2012-05-25 9:27:32 PM
Comment:
The images in this article show as big red X
Title: great done   
Name: vishwajeet singh
Date: 2010-09-30 6:44:04 AM
Comment:
its realy great thing what happend through .net 4.0

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-05-18 6:01:55 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search