Skip to content

Latest commit

 

History

History
46 lines (29 loc) · 2.69 KB

package-readme.md

File metadata and controls

46 lines (29 loc) · 2.69 KB

SQL LocalDB Wrapper

SQL LocalDB Wrapper is a .NET library providing interop with the Microsoft SQL Server LocalDB Instance API from managed code using .NET APIs. The library targets netstandard2.0, net6.0 and net8.0.

NuGet NuGet Downloads

Build status codecov

Introduction

This library exposes types that wrap the native SQL LocalDB Instance API to perform operations on SQL LocalDB such as for managing instances (create, delete, start, stop) and obtaining SQL connection strings for existing instances.

Microsoft SQL Server LocalDB 2012 and later is supported for both x86 and x64 on Microsoft Windows and the library targets netstandard2.0.

While the library can be compiled and referenced in .NET applications on non-Windows Operating Systems, SQL LocalDB is only supported on Windows. Non-Windows Operating Systems can query to determine that the SQL LocalDB Instance API is not installed, but other usage will cause a PlatformNotSupportedException to be thrown.

Basic Example

// using MartinCostello.SqlLocalDb;
using var localDB = new SqlLocalDbApi();

ISqlLocalDbInstanceInfo instance = localDB.GetOrCreateInstance("MyInstance");
ISqlLocalDbInstanceManager manager = instance.Manage();

if (!instance.IsRunning)
{
    manager.Start();
}

using SqlConnection connection = instance.CreateConnection();
connection.Open();

// Use the SQL connection...
manager.Stop();

Feedback

Any feedback or issues for this package can be added to the issues in GitHub.

License

This package is licensed under the Apache 2.0 license.