One of very important features in ORM tools is an ability to get data auto-generated by a database during the entity persistence back to your application. The Entity framework supports this feature by setting StoreGeneratedPattern in the configuration of persisted property. The StoreGeneratedPattern setting is available in both SSDL (Store schema definition language) and CSDL (Conceptual schema definition language) parts of the EDMX file. CSDL configuration allows you defining the reloading behavior in the Model-first approach but SSDL part is responsible for generating correct SQL commands which will persist the entity and reload auto-generated properties. Unfortunately for a long time this was the source of all problems.
The feature was very hard to use because of the annoying bug in the Entity designer. When we set the property in the designer, the value was saved only in CSDL part but not in SSDL part of the EDMX file and the feature didn't work until we opened the EDMX file as XML and manually modified SSDL part. This solved the problem but only until we updated our model from the database. The update always deleted whole SSDL part including our manual change so we had to do it again. Any incremental development of our models become a big pain. The workaround was using mapped stored procedures for inserting and updating entities and mapping result sets (returning auto-generated data) from these stored procedures back to the entity. Finally this bug is solved in Visual Studio 2010 SP1 and we can use StoreGeneratedPattern without any problems because the value is correctly set in both CSDL and SSDL parts and it is not overwritten during updating from the database.
Update: If you still have problem with this issue install KB2561001. It should be the most recent fix for this bug in VS 2010.
Rest of the blog post describes usage of StoreGeneratedPattern.
ADO.NET team yesterday released Microsoft Entity Framework 4.1 Release Candidate which is now available for download as both stand alone installation and NuGet package. This release provides DbContext API with code first development approach for production usage. Final release will be available next month. This version contains only minor changes to previous CTP5 version so the most of examples provided for previous version (also check great posts on Morteza Manavi's blog) should still work. ADO.NET team also released two introduction articles about code first and about database and model first with DbContext. Finally, Julia Lerman also published several screencasts about Entity Framework 4 and 4.1 and their usage in different types of applications.
The missing support for unique keys is well known limitation of Entity framework 4. Few days ago, the Entity framework team has published the article which I take as announcement of unique keys support in the next version(s) of Entity Framework. After announced support for table-valued functions, it is the second nice feature targeting the next version of Entity framework announced this year. Just be aware that "the next version" does not mean Entity Framework 4.1 (the code-first).
Update: Unfortunately this feature will not be available in the next version. ADO.NET team didn't include the feature into .NET Framework 4.5 and we will have to wait at least till a next major release (.NET Framework service pack or next version).
If you have been using inversion of control containers for a while you have most probably used some object lifetime management. The lifetime management enables reuse of existing object instances for subsequent resolution. It should be also responsible for controlling how the container will release resolved instances.
Unity offers lifetime management as classes derived from LifetimeManager. Lifetime managers in Unity are created once for each type's registration (there is an exception which I will discuss later). Every time a UnityContainer wants to create a new object instance when resolving a type it first checks with that type's lifetime manager if an instance is available. If no instance is available, the container creates an instance based on the configured constructor and passes that instance to the lifetime manager.
The following text discusses built-in lifetime managers, their behavior and usage.