Database Reference
In-Depth Information
Figure 1-5. The Entity Data Model Wizard gives you a choice between creating a model from an existing database or
starting with an empty model
Generating a model from an existing database is the Database-First approach. From the tables, views, and stored
procedures that you select from the underlying database, the wizard will create a model and entity classes, against
which you can write code. The immediate benefit here is that you write code against strongly typed entity classes,
which Entity Framework maps to the underlying database tables and columns. If the tables you include are related in
the database, these relationships will be modeled as associations. This is one way to create your model if you already
have a database for your application. However, if you prefer to use the Code-First approach with an existing database,
worry not. The Entity Framework team has created tooling ( The Entity Framework Power Tools ) that reverse-engineers
an existing database into domain entity classes, just as if you coded them by hand.
If you're working on a brand-new application, without an existing database, you have options as well. In the
Entity Framework designer, you can start with an empty design surface. Right-click the design surface to create new
EntityTypes, associations, or inheritances. You can also drag them from the Toolbox onto the design surface. Once
your model is complete, just right-click the design surface and select Generate Database from Model. This will
generate a script you can use to create the database tables and relationships for the model.
 
Search WWH ::




Custom Search