Getting Started with the ADO.NET Entity Framework

9. After you specify the necessary user name, password, and the server name, you can test your connection using the Test Connection button. When you do so, the message Test connection succeeded gets displayed in the message box as shown in the previous figure.

10. When you click on OK on the Test connection dialog box, the following screen appears: 

Note the Entity Connection String generated automatically. This connection string will be saved in the ConnectionStrings section of your application’s web.config file. This is how it will look like:

      <add name=”PayrollEntities” connectionString=”metadata=res://
        *;provider=System.Data.SqlClient;provider connection
        string=&quot;Data Source=.;Initial Catalog=Payroll;User
        providerName=”System.Data.EntityClient” />

11. When you click on Next in the previous figure, the following screen appears:

12. Expand the Tables node and specify the database objects that you require in the Entity Data Model to be generated as shown in the following figure:


13. Click on Finish to generate the Entity Data Model.

Your Entity Data Model has been generated and saved in a file named PayrollModel.edmx. We are done creating our first Entity Data Model using the ADO.NET Entity Data Model Designer tool.
Note how the Entity Types in the above model are related to one another. These relationships have been generated automatically by the Entity Data Model Designer based on the relationships between the tables of the Payroll database we created in the previous chapter.

In the next part of this article, we will learn how we can create an Entity Data Model using the EdmGen.exe command line tool. 


Leave a comment

Your email address will not be published.