Database Reference
In-Depth Information
To import the view, tables, and relationships into a model, do the following:
1.
Right-click your project, and select Add New Item.
2.
From the Visual C# Items Data templates, select ADO.NET Entity Data Model.
3.
Select Generate from database to create the model from our existing tables. Click Next.
4.
Either choose an existing connection to your database or create a new connection.
If you are creating a new connection, you will need to select your database server,
your authentication method (Windows or SQL Server), and the database. Once you have
selected these, it's a good idea to click Test Connection to be sure that the connection is
ready to go. Once you have tested the connection, click Next.
The next dialog box shows all of the tables, views, and stored procedures in the database.
Check the items you want to include in the model. We want to select all of the tables
(Meter, Poem, and Poet). We also want to select the view (vwLibrary). For now, leave
the two check boxes for pluralizing and including foreign key columns selected. We will
discuss them further momentarily. Figure 2-8 shows the things we've selected.
Figure 2-8. Selecting the tables and view to include in our model. Leave the Pluralize or singularize generated object
names and Include Foreign Key Columns in the model checked
When you click Finish, the wizard will create a new model with our three tables and the view. The wizard will also
read the foreign key constraints from the database and infer a one-to-many relationship between Poet and Poem(s)
as well as a one-to-many relationship between Meter and Poem(s).
 
Search WWH ::




Custom Search