Designing an airline passenger reservation system

4 December 2008

Tools - Part 8 - Add-ins - “Model First” in Entity Framework

Filed under: Tools — Tags: , , — Kristofer @ 13:31

In Tools Part 6 I covered SQL-DDL generation from Linq-to-SQL models using Huagati DBML Tools. The L2S version is incremental, meaning that it compares the L2S model to the underlying database and generates the DDL code necessary to change the database to match the model. This is effectively a reverse implementation of the update/sync feature in Huagati DBML Tools.

The time has now come for the first step towards “model first” using Entity Framework. A vital step towards this is the EDMX cleanup feature described in Tools Part 7; without the cleanup feature a lot of model editing in a “model first” scenario would require using an XML editor to edit the SSDL. Although not all pieces are in place in the “EDMX cleanup” feature (yet) I have added a first implementation of the SQL-DDL generator for Entity Framework models to the add-in.

This first version supports generating new databases from scratch, essentially doing what Microsoft have described in their “Model First” article in the EFDesign blog. (And what was demonstrated during their “Entity Framework futures” session at PDC2008). The next version will support incremental SQL-DDL generation identical to the L2S version described in Tools Part 6; generating scripts including only the differences between the model and the underlying database.

This functionality is available in Huagati DBML/EDMX Tools version 1.51, and can be downloaded from here. If you prefer to use the Microsoft version of the same, look out for the next release that (if I interpret all statements from MSFT correctly) will be included in Visual Studio 2010.

Step-by-step usage example

1) Download and install Huagati DBML/EDMX Tools.

Huagati DBML/EDMX Tools Installer

 

2) Fire up Visual Studio 2008 and open a Entity Framework model in the EF designer.

EF model based on Microsoft's demo database AdventureWorks 

3) Select “Generate DDL” under the “DBML/EDMX Tools” menu.

Huagati DBML/EDMX Tools' "Generate DDL" menu 

4) Wait a few seconds and you have a DDL script that will generate schemas, tables, foreign key constraints, primary keys, and indexes matching the foreign keys.

 

 

 

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

You must be logged in to post a comment.

Powered by WordPress