RepoDb is an Open Source ORM for .NET, designed to fill the gap between micro ORMs like Dapper and full-fledged ORMs like Entity Framework.
It is designed to be fast in execution and efficient in memory usage, achieving results similar to or even better than the popular Dapper library.
At the same time, RepoDb makes an effort to maintain ease of use. The provided functions are included as extension methods for IDbConnection, similar to what Dapper does.
On the other hand, besides performing queries with Raw Sql, it maintains high-level features similar to those found in Entity Framework, allowing its use with a simple syntax through lambda functions and anonymous types.
The library is compatible with major databases like SQL Server, SQLite, MySQL/MariaDb, and PostgreSQL. Additionally, it incorporates numerous additional features such as caching, tracing, and Bulk operations.
RepoDb is available as a Nuget package and is compatible with .NET Standard 2.0, making it available on Windows, Linux (Mono), and Android (Xamarin).
As mentioned at the beginning, RepoDb is Open Source. The code and documentation are available on the project page at https://github.com/mikependon/RepoDb.
Using RepoDb
Let’s look at some simple examples of using RepoDb. Before we can use RepoDB, we must initialize the library according to the data provider we are using. For example, for Sql Server we would do:
RepoDb.SqlServerBootstrap.Initialize();
This statement should be executed only once, so we typically call it from the application’s AppBootstrapper, in the service layer constructor, or in our dependency resolution system.
CRUD Operations
Once RepoDb is initialized, basic CRUD operations are as simple as:
Create an entry
var person = new Person
{
Name = "John Doe",
Age = 54,
CreatedDateUtc = DateTime.UtcNow
};
using (var connection = new SqlConnection(ConnectionString))
{
var id = connection.Insert(person);
}
Read an entry
using (var connection = new SqlConnection(ConnectionString))
{
var person = connection.Query<Person>(e => e.Id == 10045);
/* Do the stuffs for person here */
}
Update an entry
var person = new Person
{
Id = 1,
Name = "James Doe",
Age = 55,
DateInsertedUtc = DateTime.UtcNow
};
using (var connection = new SqlConnection(ConnectionString))
{
var updatedRows = connection.Update<Person>(person);
}
Delete an entry
using (var connection = new SqlConnection(ConnectionString))
{
var deletedRows = connection.Delete<Person>(10045);
}
Of course, these are just the simplest cases we can perform with RepoDb. For more information, consult the project’s website, which provides extensive documentation on the library’s features and usage.

