Skip to content

SqlInMemory is a library for creating SqlServer database on Memory instead of hard disk, at last Drops and Disposes database when you're done with it. This is useful for Integration Testing.

License

Notifications You must be signed in to change notification settings

mjebrahimi/SqlInMemory

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

78 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NuGet License: MIT Build Status

SqlInMemory

SqlInMemory is a library for creating SqlServer database on Memory instead of hard disk, at last Drops and Disposes database when you're done with it. This is useful for Integration Testing.

Note : This library uses RamDisk which also uses ImDisk in the backend for creating virtual disk drive. Therefore you have to install imdisk first. (Download link of current stable version 2.0.10)

Get Started

1. Install Package

PM> Install-Package SqlInMemory

2. Use it

Pass your connection string and it will create (mount) a virtual disk drive 'Z' and create database there finaly when disposed, drop database and unmount drive.

var connectionString = "Data Source=.;Initial Catalog=TestDb;Integrated Security=true";
using (SqlInMemoryDb.Create(connectionString))
{
    //Use database using ADO.NET or ORM

    //For example using EF Core
    services.AddDbContext<AppDbContext>(opt => opt.UseSqlServer(connectionString));
    var serviceProvider = services.BuildServiceProvider();
    var appDbContext = serviceProvider.GetService<AppDbContext>();
    appDbContext.Database.Migrate();
    //...
}

Contributing

Create an issue if you find a BUG or have a Suggestion or Question. If you want to develop this project, Fork on GitHub and Develop it and send Pull Request.

A HUGE THANKS for your help.

License

SqlInMemory is Copyright © 2020 Mohammd Javad Ebrahimi under the MIT License.

About

SqlInMemory is a library for creating SqlServer database on Memory instead of hard disk, at last Drops and Disposes database when you're done with it. This is useful for Integration Testing.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages