Skip to main content

Posts

Showing posts with the label entity framework

Keep Your Database In Sync With Application: Fluent Migrator

In this post, we continue to explore ways to free your application from being tightly bound to the Entity Framework environment. The primary goal is to offer an alternative solution that is not only more flexible and robust but also gives you, as a developer, greater control over database manipulation with less abstraction and complexity. Here, we introduce a library for database migrations, which serves as a natural extension to tools like Dapper and SqlKata . Fluent Migrator Fluent Migrator  is a library designed for managing database migrations, giving you complete control over the execution and how migrations are written. It offers greater flexibility compared to standard EF migrations, which are closely tied to EF entities and generated automatically, often accompanied by additional overhead, including extra snapshot files. In the code snippet below, you’ll find a simple migration class. This class includes two methods that override the base Migration class, allowing you to d...

Dapper On Steroids: SqlKata

Dapper is a lightweight, high-performance ORM for .NET. It is widely used because of its simplicity and speed. Dapper in its essence provides simple mapping to POCO and works with raw queries minimizing the overhead. On the other hand it lacks of flexibility in terms of query writing, because we need to write queries like static strings. One simple example is shown in the code snippet below. using System; using System.Data.SqlClient; using Dapper; class Program { static void Main(string[] args) { using (var connection = new SqlConnection("connection_string")) { connection.Open(); string sql = "SELECT * FROM Companies"; var companies = connection.Query<Company>(sql); } } } With the lack of flexibility in query construction, we would be in temptation to go for Entity Framework or some other heavy weight ORM, but there is also a simple library ( SqlKata ) which provides a decent flexibil...