Code through the pain Ladislav Mrnka's professional blog about software development


This article is about "improvement" in Visual Studio 2012 unit testing. I think it doesn't happen very often to have an upgrade which makes the functionality worse than the previous version. In the case of the new Test Explorer window we can even talk about removing previously available functionality because the new window is mostly useless for any bigger solution. Until Microsoft improves the window we are not away from the testing experience known before Visual Studio 2008 when we didn't have any built in support for unit testing and we had to use third party plugins or external test runners.

I wanted to write this article immediately after I tried the new Test Explorer in Visual Studio 2012 Ultimate RC but I still believed that Microsoft will improve it before launching Visual Studio 2012 especially when complains to the new Test Explorer appeared long time before RC. Unfortunately Visual Studio 2012 RTW was released with the same Test Explorer window and there is also no update available yet. Test Explorer window should be hopefully improved this fall. There is also related request on Visual Studio User Voice with few other suggestions for improvements in comments.

The rest of the article describes what is wrong with the new window and compares the functionality with Visual Studio 2010 and Resharper 7.

Posted on September 16, 2012 by Ladislav Mrnka
Filed under: Visual Studio
Continue reading

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.

Posted on March 17, 2011 by Ladislav Mrnka
Filed under: Entity framework
Continue reading