In previous post, I showed you how to implement a custom migration without using Entity Framework for Sqlite database in .Net core. In this post, I’ll use Entity Framework Migration to manage (upgrade / downgrade) our database structure. Both of approaches will work, you can choose one of 2 solutions as you prefer.
In previous post Entity Framework Code First Basic FAQ – Part 1, I discuss some frequently asked questions when I start working with Entity Framework Code First. This post will follow the spirit of the previous one, some interesting points of Entity Framework will be demonstrated in short code listings. In source code sample, you’ll find 2 projects, the project numbered with number 2 is for this post.
Last month I’ve a chance to develop an app using Sqlite and Entity Framework Code First. Before I started with this project, I thought everything will be easy because Sqlite and Entity Framework are both popular framework. Maybe I just need to install some nuget packages and it will work like a charm. But… yes, there is always a ‘but’ later, it’s just not so easy. Especially when I usually work with NHibernate than Entity Framework. The installation doesn’t complete his job when configuring the .config file (or maybe it just happens for me or does the author do it with intentionally?) and the Migration for Sqlite Entity Framework Code First is not supported (please correct me if I’m wrong). There are, of course, commercial products for Sqlite Migration but I prefer an open source framework or something free :). So in this post I would like to write down the steps required when starting a project for Sqlite Entity Framework Code First and how I make my own simple Migration engine.
The Entity Framework (EF) with Code First is so popular that any database developer should own skills for this kind of development. If you make a search of EF with Code First, you’ll find tons of tutorial figuring out how it works and all things relevant. Therefore in this blog post, I don’t intend to give you something new, indeed there is nothing new. I just want to make a summary of all necessary basic steps when I start a project with EF Code First. So if you’re already professional with EF, just skip this post.
MVVM – Model View ViewModel is the new design pattern originated from Microsoft, introduced by Martin Flower in 2004 and widely used after a publication of Josh Smith on MSDN magazine in 2009. MVVM is targeted at modern user interface development platforms such as WPF and Silverlight which are completely differently designed to traditional developer. Although MVVM bases on MVC – Model View Controller, the ViewModel is more better because it provides an easier way to expose and cosume data objects from the Model and therefore can handle the display logic of View. Despite of the great data binding functions of WPF, in MVVM we do not have to write any code in the View layer anymore. The View and Model layer are completely seperated which means the designers can use native WPF markup language XAML and create bindings to the ViewModel ,which is written by application developers, without writing any code behind the View. The designers can then focus on their designs rather than developing the business logic behind and therefore the software development can be better controlled,easier for bugfixing and transparenter. That’s short description about MVVM and its advantages. I think MVVM is not the hot topic anymore so if you want, you can find a lot of interesting articles on internet. In this blog post, I just want to try the MVVM Light Toolkit to generate automatically a MVVM application for me when I create a new application because until now I must create the pattern myself manually.