Kros.Utils.MsAccess 2.2.0

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

Kros.Utils.MsAccess Build Status

Kros.Utils.MsAccess is a general library of various utilities to simplify the work of a programmer with Microsoft Access databases.

For some (especially database) stuff to work properly, the library needs to be initialized when the program starts by calling LibraryInitializer.InitLibrary.

Library is compiled for .NET Framework 4.6.

Documentation

For configuration, general information and examples see the documentation.

Download

Kros.Libs is available from Nuget Kros.Utils.MsAccess

Contributing Guide

To contribute with new topics/information or make changes, see contributing for instructions and guidelines.

This topic contains following sections

Kros.Utils.MsAccess

MsAccess General Utilities

The MsAccessDataHelper class contains general utilities for working with the MS Access database connection.

MsAccess Database Schema

It is very easy to get a database schema. Since the acquisition of the schema is a time-consuming operation the loaded scheme is held in a cache and the next schema is retrieved. The database schema includes the TableSchema tables, their ColumnSchema columns and IndexSchema indexes.

OleDbConnection cn = new OleDbConnection("MS Access Connection String");

DatabaseSchema schema = DatabaseSchemaLoader.Default.LoadSchema(cn);

MsAccess Bulk Operations - Bulk Insert and Bulk Update

Inserting (INSERT) and updating (UPDATE) large amounts of data in a database are time-consuming. Therefore, support for rapid mass insertion, Bulk Insert and a fast bulk update, Bulk Update. The IBulkInsert and IBulkUpdate interfaces are used. They are implemented for MsAccess database in the MsAccessBulkInsert and MsAccessBulkUpdate classes. As a data source, it serves any IDataReader or DataTable table.

Because IDataReader is an intricate interface, you just need to implement the simplier interface IBulkActionDataReader. If the source is a list (IEnumerable), it is sufficient to use the EnumerableDataReader<T> class for its bulk insertion.

private class Item
{
    public int Id { get; set; }
    public string Name { get; set; }
}

public void InsertManyItems()
{
    IEnumerable<Item> data = GetData();

    using (var reader = new EnumerableDataReader<Item>(data, new string[] { "Id", "Name" }))
    {
        using (var bulkInsert = new MsAccessBulkInsert("connection string"))
        {
            bulkInsert.Insert(reader);
        }
    }
}

MsAccess Unit Testing Helpers

Standard unit tests should be database-independent. But sometimes it is necessary to test the actual database because the test items are directly related to it. To test the actual database you can use the MsAccessTestHelper class. It creates a database for testing purposes on the server and runs tests over it. When tests are finished the database is deleted.

private const string BaseDatabasePath = "C:\testfiles\testdatabase.accdb";

private const string CreateTestTableScript =
@"CREATE TABLE [TestTable] (
    [Id] number NOT NULL,
    [Name] text(255) NULL,

    CONSTRAINT [PK_TestTable] PRIMARY KEY ([Id])
)";

[Fact]
public void DoSomeTestWithDatabase()
{
    using (var helper = new MsAccessTestHelper(ProviderType.Ace, BaseDatabasePath, CreateTestTableScript))
    {
        // Do tests with connection helper.Connection.
    }
}
Product Compatible and additional computed target framework versions.
.NET Framework net48 is compatible.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Kros.Utils.MsAccess:

Package Downloads
Kros.KORM.MsAccess

KORM.MsAccess is fast, easy to use, micro .NET ORM tool for MsAccess. (Kros Object Relation Mapper)

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.2.0 37 5/6/2026
2.1.0 103 4/22/2026
2.0.0 145 2/18/2026
1.9.0 1,248 7/9/2021
1.8.0 2,661 12/13/2019
1.7.0 1,489 12/13/2019
1.6.3 872 10/29/2019
1.6.2 2,524 8/1/2018
1.6.1 1,957 7/2/2018
1.6.0 1,652 6/22/2018
1.5.0 1,612 5/29/2018
1.4.7 1,652 4/24/2018
1.4.6 1,976 4/18/2018