DuckDB.NET.Data 1.5.6.1

dotnet add package DuckDB.NET.Data --version 1.5.6.1
                    
NuGet\Install-Package DuckDB.NET.Data -Version 1.5.6.1
                    
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="DuckDB.NET.Data" Version="1.5.6.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DuckDB.NET.Data" Version="1.5.6.1" />
                    
Directory.Packages.props
<PackageReference Include="DuckDB.NET.Data" />
                    
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 DuckDB.NET.Data --version 1.5.6.1
                    
#r "nuget: DuckDB.NET.Data, 1.5.6.1"
                    
#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 DuckDB.NET.Data@1.5.6.1
                    
#: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=DuckDB.NET.Data&version=1.5.6.1
                    
Install as a Cake Addin
#tool nuget:?package=DuckDB.NET.Data&version=1.5.6.1
                    
Install as a Cake Tool

DuckDB.NET

DuckDB bindings for C#

GitHub Workflow Status Coveralls License Ko-Fi Discord

NuGet DuckDB.NET.Data NuGet DuckDB.NET.Bindings

NuGet DuckDB.NET.Data.Full NuGet DuckDB.NET.Bindings.Full

Project Icon

Usage

dotnet add package DuckDB.NET.Data.Full
using (var duckDBConnection = new DuckDBConnection("Data Source=file.db"))
{
  duckDBConnection.Open();

  using var command = duckDBConnection.CreateCommand();

  command.CommandText = "CREATE TABLE integers(foo INTEGER, bar INTEGER);";
  var executeNonQuery = command.ExecuteNonQuery();

  command.CommandText = "INSERT INTO integers VALUES (3, 4), (5, 6), (7, 8);";
  executeNonQuery = command.ExecuteNonQuery();

  command.CommandText = "Select count(*) from integers";
  var executeScalar = command.ExecuteScalar();

  command.CommandText = "SELECT foo, bar FROM integers";
  var reader = command.ExecuteReader();

  PrintQueryResults(reader);
}

private static void PrintQueryResults(DbDataReader queryResult)
{
  for (var index = 0; index < queryResult.FieldCount; index++)
  {
    var column = queryResult.GetName(index);
    Console.Write($"{column} ");
  }

  Console.WriteLine();

  while (queryResult.Read())
  {
    for (int ordinal = 0; ordinal < queryResult.FieldCount; ordinal++)
    {
      var val = queryResult.GetInt32(ordinal);
      Console.Write(val);
      Console.Write(" ");
    }

    Console.WriteLine();
  }
}

MotherDuck

To connect to MotherDuck:

using var duckDBConnection = new DuckDBConnection("DataSource=md:{your_database}?motherduck_token=ey...");

DuckDB Extensions (C#)

If you want to build DuckDB extensions with C#, see Giorgi/DuckDB.ExtensionKit.

Known Issues

When debugging your project that uses DuckDB.NET library, you may get the following error: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. The error happens due to debugger interaction with the native memory. For a workaround check out Debugger Options mess up debugging session during Marshalling

Documentation

Documentation is available at https://duckdb.net

Support

If you encounter a bug with the library Create an Issue. Join the DuckDB dotnet channel for DuckDB.NET-related topics.

Contributors

Contributors

Sponsors

A big thanks to DuckLabs and AWS Open Source Software Fund for sponsoring the project!

DuckLabs

AWS

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  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 (13)

Showing the top 5 NuGet packages that depend on DuckDB.NET.Data:

Package Downloads
DuckDB.InteractiveExtension

DuckDB support for Polyglot Notebooks

Microsoft.SemanticKernel.Connectors.DuckDB

DuckDB connector for Semantic Kernel plugins and semantic memory

EnergyExemplar.EntityFrameworkCore.DuckDb

Seamless integration between Entity Framework Core and DuckDB, providing significant performance improvements for analytical queries with a simple, developer-friendly API. Note: this package does not include the DuckDB or SQLite native libraries — you must add the appropriate DuckDB.NET or SQLite driver package separately.

NetEvolve.HealthChecks.DuckDB

Contains HealthChecks for DuckDB, based on the nuget package `DuckDB.NET.Data`.

Mostlylucid.LucidRAG.DataSummarizer

Core data file processing pipeline for CSV, JSON, Excel, Parquet, and SQLite database ingestion with relationship detection

GitHub repositories (5)

Showing the top 5 popular GitHub repositories that depend on DuckDB.NET.Data:

Repository Stars
dotnet/interactive
.NET Interactive combines the power of .NET with many other languages to create notebooks, REPLs, and embedded coding experiences. Share code, explore data, write, and learn across your apps in ways you couldn't before.
erikdarlingdata/PerformanceMonitor
Free, open-source SQL Server and Postgres performance monitoring. Collectors, real-time alerts, graphical plan viewer, MCP server for AI analysis. Supports SQL 2016-2025, Azure SQL, AWS RDS, Postgres, Aurora Postgres.
Hitmasu/OpenCNPJ
API pública de busca e consulta de CNPJs do Brasil
buildersoftio/cortex
Cortex | Data Framework—a cutting-edge SDK that simplifies real-time data processing with intuitive operators, robust state management, and seamless telemetry for efficient, scalable pipelines.
jacking75/programming-books-with-ai
AI 와 같이 만든 프로그래밍 책들
Version Downloads Last Updated
1.5.6.1 97 10/15/2026
1.5.6 7,150 9/28/2026
1.5.5 37,242 7/26/2026
1.5.3 26,334 5/24/2026
1.5.2 45,510 4/24/2026
1.5.0 26,520 3/10/2026
1.4.4 22,424 2/3/2026
1.4.4-alpha.2 523 12/19/2025
1.4.3 24,438 12/11/2025
1.4.1 41,858 10/13/2025
1.3.2 27,566 7/8/2025
1.3.0 32,651 6/3/2025
1.2.1 5,871 3/5/2025
1.2.1-alpha.8 205 2/19/2025
1.2.0 8,654 2/6/2025
1.1.3 92,525 11/7/2024
1.1.2.1 43,271 10/21/2024
1.1.2-alpha.5 196 10/10/2024
1.1.1 14,058 9/24/2024
Loading failed

- Built on DuckDB v1.5.6

New features:
- Read a TIME column as TimeSpan
- Read FLOAT as double, DOUBLE as float, and both as decimal, in columns, list items, maps and structs
- Read HUGEINT and UHUGEINT columns as DuckDBHugeInt and DuckDBUHugeInt with GetFieldValue and GetProviderSpecificValue
- The mapped appender now accepts DuckDBDateOnly and DuckDBTimeOnly properties, and scalar functions accept them as parameters and results
- BigInteger values can now be bound and appended to UHUGEINT columns as unsigned values, including through the mapped appender
- A table function over an array now uses the length of the array as its cardinality hint when none is given

Performance (measured against 1.5.6 on .NET 10 with a million rows; the gains are in moving values between DuckDB and .NET, so bulk appends, reading large results and queries that call C# functions benefit most, while queries dominated by DuckDB's own work change little):
- Reading numbers and booleans through GetInt32, GetFieldValue<T> and the other typed getters 3.5 to 6 times faster, an integer column read as double 12 times faster
- Reading short strings up to 1.35 times faster
- Reading dates, times and timestamps 3 to 12 times faster, appending a DateTime 14 to 26 times faster
- UUID, DECIMAL and HUGEINT reads 1.7 to 7 times faster
- Typed scalar functions 5 to 8 times faster, 1.6 times with a string argument
- Table functions 2.5 to 6 times faster
- With projection pushdown, the columns a query does not read are no longer computed: a query that reads one column of a four-column table function is about 6 times faster, and the gain grows with the number of unread columns
- LIST, STRUCT and MAP columns read into .NET types up to 6 times faster
- Appending BigInteger, lists, strings, C# enums and through the mapped appender 1.3 to 4 times faster; numbers 1.2 to 1.4 times faster; decimals of up to 18 digits 1.3 to 2 times faster depending on the CPU, wider decimals more than twice as fast

Memory (per million rows, against 1.5.6):
- Appending no longer allocates for each value. 1.5.6 allocated about 750 bytes for every DateTime (2.9 GB for four TIMESTAMP columns), 756 MB for a record of mixed types in the mapped appender, 211 MB for lists of int?, 188 MB for C# enums and up to 315 MB for BigInteger; each is now about 0.1 MB
- Scalar functions with nullable arguments or results, and table functions over structs or rows with nullable columns, no longer allocate for each row: 21 to 47 MB in 1.5.6, now about 0.1 MB
- An integer read as double no longer allocates (375 MB for eight million values in 1.5.6), a DECIMAL wider than 18 digits is read without a BigInteger (107 MB, now none), and a large HUGEINT read as BigInteger allocates a third as much
- LIST, STRUCT and MAP reads allocate up to 60% less, and GetValues 9 to 17% less

Fixes:
- A Read() after the end of a streaming result, and the first Read() of an empty streaming result, no longer throw (#358)
- Reading an ENUM column as a type other than string no longer reads past the stored value
- Reading a BIT column as an unsupported type throws InvalidCastException instead of ending the process with a stack overflow
- Negative intervals can be read as TimeSpan, bound and appended
- A TIMETZ read as DateTimeOffset no longer throws for a time earlier in the day than its positive offset
- -2^127 is accepted as a HUGEINT value, and the HUGEINT limits no longer fail under cultures with another minus sign
- A decimal parameter is sent with the exact number of its digits; 1000 was sent as DECIMAL(3,0)
- A list parameter that DuckDB cannot build is refused instead of crashing the process
- The exception of a scalar function that throws in WHERE or HAVING is now the InnerException of the error
- A table function projection that calls a constructor (a record or a tuple) is refused with a clear message instead of a NullReferenceException
- The mapped appender disposes its appender when validation fails
- DuckDBClientFactory.CanCreateCommandBuilder and CanCreateDataAdapter return false instead of throwing

Behavior changes:
- Appending a decimal too wide for its column throws instead of storing a value the column cannot hold
- A TimeSpan parameter where DuckDB cannot infer the type is bound as an INTERVAL instead of as text; declare DbType.Time to bind it as a time
- Looking up a missing parameter by name through DbParameterCollection throws IndexOutOfRangeException, as the typed indexer does
- A TIMETZ read as DateTimeOffset is placed on 0001-01-02 instead of 0001-01-01
- A BigInteger parameter where DuckDB cannot infer the type is bound as HUGEINT if it fits, as UHUGEINT up to 2^128 - 1 and as BIGNUM beyond, instead of throwing for values outside the HUGEINT range