For those of you who subscribe to VSJ, UK software journal, this month in the May edition hopefully you read my Introduction ADO.net Entity Framework article. It is a huge framework and the aim of my article was to demystify some of the terms and how they all link together, I feel it archives this aim.
For those of you who don’t subscribe, you can find the article online at http://www.vsj.co.uk/articles/display.asp?id=720.
One of the main problems with Linq to SQL was the fact that you couldn’t easily refresh your diagram to take into account schema changes.
I was really pleased to see that in the Entity Framework tools they have the ability to update model from database. Simply right click the NorthwindModel.Store in the Model Browser and click the option to update.
You then have the ability to Add, Update or Delete items from your model.
However, not all is same it seems….
I created a model with all the tables from my database. I then later went back and removed all the entities apart from Customer, Order and Order_Details. After selecting to update my model, I unticked the Add checkbox as I didn’t want anything being added. I then wanted to uncheck the other tables which I wasn’t interested in but got the error “Items for update and delete cannot be checked or unchecked”, this was a bit odd but fair enough.
So I clicked finish and it added all of the removed entities back into my model! Not what I expected to happen at all.
To make matters worse, the column I dropped was still in my table! I tried to add a column and that didn’t appear either until I deleted and re-added the table.
Anyone have any ideas on the expected behaviour of this feature??
Tonight I was taking an in-depth look at the Entity Framework bits. After creating my C# console application, I went to add the new ADO.NET Entity Data Model. After adding the item, I selected that the model should contain objects generated from database. After clicking next, the dialog closes – not great!
Next step was to generate the model manually, however this also gave me a type initialise exception, finally after closing VS2008 it crashed and gave Vista’s lovely error reporting messages.
The solution was a quick reinstall of the Entity Framework Tools CTP 2 soon shorted it out, it either didn’t install correctly or I didn’t install it (which is strange as I had the templates installed inside VS).