In this post, I am trying to add some CQRS principles onto my EFMVC project. EFMVC is a small web app for demonstrating ASP.NET MVC and EF Code First. Please keep in mind that this is not the implementation CQRS patterns, but trying to add some CQRS flavors on the Solution Architecture with Commands that changes the data (Create, Update and Delete). The current implementation of command execution is implemented in a synchronous way.
A while ago, I have released EFMVC, a demo web app built using ASP.NET MVC 3, EF Code First and Unity. The EFMVC app has demonstrated many architectural patterns and practices such as Generic Repository, Repository pattern, Unit of Work pattern, Dependency Injection pattern and Application Service later. Today I would like to announce the release of EFMVC 1.0 Preview. This release is an early preview release that has made some changes in the solution architecture. The preview is written in ASP.NET MVC 3 version and will be migrated to ASP.NET MVC 4 with new features on later.
EF Code First Framework is using a table named EdmMetadata on the database to check the current model is compatible with the database. When your model is changing, you need to drop the database and create a new database. In that scenario, you can add a initialization strategy using DropCreateDatabaseIfModelChanges<TContext>. You can avoid the EdmMetadata table from your database so it won't check the schema of database with model. When you are using Code First Migrations or updating your database schema is manually, you don't need to EdmMetadata on the database. The following code in the DbContext class will not create EdmMetadata on the database.