Key Highlights

  • Provides a unified interface for executing SQL Server CRUD operations.
  • Supports both synchronous and asynchronous database queries.
  • Handles parameterized queries to prevent SQL injection.
  • Automatically maps query results to strongly-typed objects using reflection.
  • Includes built-in transaction management (begin, commit, rollback).
  • Offers flexible methods for retrieving data as lists, single objects, DataTables, DataSets, or JSON.
  • Integrates optional event logging for error tracking on Windows systems.
  • Implements IDisposable for proper resource cleanup.
  • Supports both stored procedures and raw SQL text commands for flexible querying.
  • Parameter mapping is automatic from object properties, reducing manual code and errors.
  • Handles structured parameters (e.g., table-valued parameters) for advanced SQL Server features.
  • Provides overloads for most methods to accommodate different usage scenarios (with/without parameters, generic types, etc.).
  • Implements robust error handling with optional event logging for diagnostics.
  • Ensures proper resource management with IDisposable and automatic cleanup of connections and commands.
  • Designed for .NET 8 and C# 12, leveraging modern language features and async/await patterns.
  • Seamlessly integrates with your project's unit testing framework for reliable and maintainable code.

Why Database Library MDS?

Writing data access code is repetitive and error-prone. Database Library MDS eliminates boilerplate by providing a clean, consistent API for all your SQL Server operations. Whether you're querying a single record, executing bulk updates, or managing transactions, this library handles the complexity so you can focus on business logic.

Getting Started

Database Library is built on two different SqlClient libraries to support both modern and legacy .NET applications:

  • MDS uses Microsoft.Data.SqlClient — recommended for .NET 8, .NET 9, .NET 10, and all new projects
  • SDS uses System.Data.SqlClient — for legacy .NET Framework 4.8 compatibility only

Both editions provide the same powerful API with automatic connection management, parameter binding, and result mapping.

đŸ“Ļ Install via NuGet

Database Library MDS Recommended for most projects
dotnet add package DatabaseLibraryMDS
NuGet\Install-Package DatabaseLibraryMDS
Database Library SDS Legacy Framework
dotnet add package DatabaseLibrarySDS
NuGet\Install-Package DatabaseLibraryMDS
💡 Which package should I choose?
  • MDS (Microsoft.Data.SqlClient): Modern, actively maintained SqlClient library. Recommended for .NET 8, .NET 9, .NET 10, and all new projects.
  • SDS (System.Data.SqlClient): Legacy SqlClient library. Use only for compatibility with .NET Framework 4.8 applications or when migration is not yet possible.

â„šī¸ Microsoft recommends Microsoft.Data.SqlClient (MDS) for all new development targeting .NET 8+. It includes the latest features, security updates, and performance improvements.

After installation, inject ISqlServer into your services and start using the library. Check the API Reference tab for the complete list of available methods.

An unhandled error has occurred. Reload 🗙