SqlKata.EntityFrameworkCore 1.0.7

dotnet add package SqlKata.EntityFrameworkCore --version 1.0.7
                    
NuGet\Install-Package SqlKata.EntityFrameworkCore -Version 1.0.7
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SqlKata.EntityFrameworkCore" Version="1.0.7" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SqlKata.EntityFrameworkCore" Version="1.0.7" />
                    
Directory.Packages.props
<PackageReference Include="SqlKata.EntityFrameworkCore" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SqlKata.EntityFrameworkCore --version 1.0.7
                    
#r "nuget: SqlKata.EntityFrameworkCore, 1.0.7"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SqlKata.EntityFrameworkCore@1.0.7
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SqlKata.EntityFrameworkCore&version=1.0.7
                    
Install as a Cake Addin
#tool nuget:?package=SqlKata.EntityFrameworkCore&version=1.0.7
                    
Install as a Cake Tool

SqlKata.EntityFrameworkCore SqlKata.EntityFrameworkCore SqlKata.EntityFrameworkCore build

A lightweight, fluent integration library that seamlessly connects SqlKata's powerful query builder with Entity Framework's DbContext.
Build complex SQL queries using your existing Entity Framework models without the limitations of LINQ.

Features

  • Directly query EF entities using SqlKata's fluent syntax
  • Automatic table name resolution from DbContext
  • ~Strong typing support for column selection~
  • ~Built-in mapping of query results to entity objects~
  • ~Transaction support~
  • Comprehensive extension methods for DbContext and DbSet
  • Performance optimized with minimal overhead

Requirements

  • .NET 10 or later
  • Entity Framework Core 10 or later
  • SqlKata 4 or later

Installation

dotnet add package SqlKata.EntityFrameworkCore

Example without SqlKata.EntityFrameworkCore

Typically, if you're using DbContext, executing a query against your database using SqlKata would look like this:

var QueryCompiler = new SqliteCompiler();
var InsertQuery = new Query("users").AsInsert(new { email = "john.doe@example.com", username = "John", password = "Example123!#", created_at = DateTime.UtcNow, updated_at = DateTime.UtcNow });
var CompiledInsertQuery = QueryCompiler.Compile(InsertQuery);
_ = SomeDbContext.Database.ExecuteSqlRaw(CompiledInsertQuery.Sql, CompiledInsertQuery.Bindings.ToArray());

There are multiple things annoying with this:

  • You have to instantiate a compiler, cache it to avoid constantly re-instantiating.
  • You have to create a query, and hardcode the table name you're querying against.
  • You have to compile the query, save it into a variable, and pass it to ExecuteSqlRaw.

This is WAY too much work for a simple query, and that's exactly where our library comes into play!

Example with SqlKata.EntityFrameworkCore

With our library, all you have to do is:

  • Specify which compiler you want to use (only one single time).
  • The actual query.
// Specify the compiler that must be used for all future queries.
SqlKataEntityFramework.SetDefaultCompiler<SqliteCompiler>();

// Insert the user.
_ = Db.Database.ExecuteSqlKata(T => T.From(Db.Users).AsInsert(new { email = "jane.doe@example.com", username = "Jane", password = "Example123!#", created_at = DateTime.UtcNow, updated_at = DateTime.UtcNow }));

// Fetching data is even more simple.
_ = Db.Users.FromSqlKata(T => T.Select("*").Where("id", 1)).Single();

// Async variants are available too, with optional cancellation tokens.
_ = await Db.Database.ExecuteSqlKataAsync(T => T.From(Db.Users).AsUpdate(new { username = "Jane Doe" }).Where("id", 1), cancellationToken);
_ = await Db.Users.FromSqlKata(T => T.Where("id", 1)).SingleAsync(cancellationToken);

When the query has no From(...) clause, FromSqlKata uses the table mapped to the DbSet automatically.

License

You are free to use this library however you or your company wants to.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.7 346 9/16/2026
1.0.6 3,575 3/30/2025
1.0.5 9,300 2/21/2023
1.0.3 1,228 9/18/2022
1.0.2 1,210 5/9/2022
1.0.1 1,131 5/9/2022
1.0.0 1,119 5/9/2022