In the last few days I have been learning how to use the Microsoft Entity Framework 4.0, LINQ to SQL, Entity SQl, and more. Specifically, I started working on a brand new project, so I was able to use the “Model First” approach.
The Entity Data Model consists of the CSDL, the MSL,
the SSDL, and the generated DDL (SQL Scripts)
As I started working with the .EDMX file in Visual Studio I started researching articles and books that could help me out – and found this great article:
Model-First in the Entity Framework 4, by Jon Fancey, July 2010
http://msdn.microsoft.com/en-us/library/ff830362
Summary: In this paper we'll look at the new Entity Framework 4 that ships with .NET Framework 4 and Visual Studio 2010. I'll discuss how you can approach it's usage from a model-first perspective with the premise that you can drive database design from a model and build both your database as well as your data access layer declaratively from this model. The model contains the description of your data represented as entities and relationships providing a powerful approach to working with ADO.NET, creating a separation of concerns through an abstraction between a model definition and its implementation.
The author has an example on how to extend the DDL generation – allowing you to define indexes on Scalar Properties in your model. Unfortunately, the given example did not work - so after I found the issue and got it working, I wrote up this tutorial. Follow the instructions below to add extended properties to your model (CSDL) so when you generate your .SQL script (DDL) you'll create indexes on specific scalar properties you've defined.
See below for the tutorial and links I found useful while learning how to use the Entity Framework. I have been using .netTiers (http://nettiers.com/), an awesome ORM set if tenplates for CodeSmith (http://codesmithtools.com/) for a few years, but now that Microsoft has its own ORM (the Entity Framework) and its data strategy is clearly set on EF, it’s a good idea to learn it and use it.
Continue reading "Microsoft Entity Framework 4: extending your DDL generation by adding indexes on Scalar Properties" »