Last night I gave a presentation on the ADO.NET Entity Framework at the Denver Visual Studio User Group. It was a great discussion and the questions from the audience helped me tell the story I was trying to tell. That story is that the Entity Framework is a great data access tool. It’s extendable and in turn flexible enough to meet the needs of the small point solutions to the enterprise caliber solutions. What I really like about it is the ability to start simple. Let’s get a solution up and running and then go back and extend\refactor certain areas to improve the architecture and\or performance. That’s not saying we shouldn’t do some design work up front, but let’s start by getting a solid solution built and then add on features and improvements in the future.
Sometimes I think architects focus too much on creating the perfect architecture instead of creating a flexible one. The solution just needs to work given the current requirements. Beyond that, it also needs to be flexible so it can change when new requirements and features get defined. EF lends itself very well to flexibility and extensibility.
The zip file below contains the final solution. That solution has all the extensions we did to the context as well as the entities in the context. It also includes a basis for a validation framework. The validation framework could use some tweeks to make it better. I leave that to you and your creative minds.
The zip file also contains a SQL script that will quickly and easily create the sample DB for you. Both the schema and the data. All you need to do is change the location of the DB file (.mdf) and the log file (.ldf) in order to run the script. Once you get the DB created you will have to change the server name in the connection string located in the web.config. After that everything should run great. Here is the zip:
EFDemoes.zip
I hope that you enjoyed the talk. If you would like the step by step guide to creating the initial model and setting up the inheritance please visit Rob Bagby’s blog of EF.