Repolode
dotnetcore

dotnetcore/FreeSql

FreeSql is a .NET ORM supporting AOT, code-first migrations, and many databases including MySQL, PostgreSQL, SQL Server, Oracle, SQLite and several Chinese domestic databases.

Stars
4,409
Forks
910
Open issues
179
Last commit
7 days ago

What is it?

FreeSql is an object-relational mapping library for .NET that targets .NET Core 2.1+, .NET Framework 4.0+, Xamarin and AOT scenarios. Developers define entity classes in C# or VB.NET and use a fluent API to query, insert, update and delete data through a single IFreeSql instance.

It covers schema work as well as data access. Code-first migration keeps tables in sync with entity definitions, and DbFirst can generate entity classes from an existing database. Navigation properties support one-to-many and many-to-many relationships with include and lazy loading, and expression-based queries can be customized.

The library supports a broad set of databases, including MySQL, SQL Server, PostgreSQL, Oracle, SQLite, Firebird, ClickHouse, DuckDB, TDengine, QuestDB and MS Access, along with domestic databases such as DM (达梦), KingbaseES (人大金仓) and GBase (南大通用). It also offers read/write separation, table and database sharding, global filters, and optimistic and pessimistic locking.

Key features

  • 01Code-first data migration and DbFirst entity generation from existing databases
  • 02Navigation properties with one-to-many, many-to-many, include and lazy loading
  • 03Expression-based queries with customizable analysis
  • 04Read/write separation, table and database sharding, and global filters
  • 05Optimistic and pessimistic locking support
  • 06Works across many relational, analytical and embedded databases, including several Chinese domestic databases

Use cases

  • Building .NET backends that need to target several databases with one data access layer
  • Working with Chinese domestic databases such as DM, KingbaseES or GBase from .NET
  • Adding read/write splitting or table sharding to a high-volume .NET application
  • Generating entity classes from an existing database schema

Quick start

  1. 1

    Install the SQLite provider package

    dotnet add package FreeSql.Provider.Sqlite
  2. 2

    Create the singleton IFreeSql instance with a connection string

  3. 3

    Define entities and query data with fsql.Select<T>()

In collections

Topics

FAQ

What is FreeSql?
FreeSql is a .NET ORM supporting AOT, code-first migrations, and many databases including MySQL, PostgreSQL, SQL Server, Oracle, SQLite and several Chinese domestic databases. FreeSql is an object-relational mapping library for .NET that targets .NET Core 2.1+, .NET Framework 4.0+, Xamarin and AOT scenarios. Developers define entity classes in C# or VB.NET and use a fluent API to query, insert, update and delete data through a single IFreeSql instance.
Is FreeSql free to use? What license does it have?
FreeSql is open source under the MIT license. Check the license terms before using it in commercial products.
Is FreeSql still maintained?
Actively maintained. The last commit to FreeSql was on Nov 1, 2026.
What can I use FreeSql for?
Building .NET backends that need to target several databases with one data access layer Working with Chinese domestic databases such as DM, KingbaseES or GBase from .NET Adding read/write splitting or table sharding to a high-volume .NET application Generating entity classes from an existing database schema
How do I install FreeSql?
Install the SQLite provider package: dotnet add package FreeSql.Provider.Sqlite Create the singleton IFreeSql instance with a connection string Define entities and query data with fsql.Select<T>()
Where can I get FreeSql?
The source code and installation instructions are on GitHub: https://github.com/dotnetcore/FreeSql

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects