Git Product home page Git Product logo

ef-ephemeral-localdb's Introduction

EF Core Ephemeral LocalDB Instance

In this repository I prototype spinning up an ephemeral SQL Server LocalDB instance for EF Core. This should be useful as a replacement for the in-memory provider most commonly used for tests. The advantage of using this over it should be the option of ExecuteSql/FromSql, views, UDFs etc.

It works by invoking sqllocaldb to create and delete the instance. The instance ben be scoped to both a file name and an assembly name, so one DB per executable path or per any instance of application on the system, respectively.

Creating and deleting the database will be encapsulated in the UseLocalDb extension method if it is possible to hook into the DB context destructor from there. We need that to be able to release the SQL LocalDB instance. Additionally, for all but NewGuid scopes we will need to make sure the context is last so that we do not stop and delete the instance prematurely.

Tests are usually ran not only locally, but also as a part of continuous integration / delivery. I aim to also find out if SQL Server LocalDB can be installed into Azure Pipelines so that this solution could work in both a developer's local environment as well as the remote build scenario.

It should be: https://github.com/Microsoft/azure-pipelines-image-generation/issues/34

If it is not present in the GA Microsoft hosted pipelines, it looks like the only option would be to use a self-hosted agent with LocalDB installed in its image. But maybe there are other options.

To-Do

Redo to be an extension to the options builder (UseLocalDb(scope))

Consider removing the idea of the scope entirely and provide user just with the methods

Find out if SQL Server LocalDB is installed in GitHub Actions Windows agent

ef-ephemeral-localdb's People

Contributors

tomashubelbauer avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.