EntityFrameworkCore FlatFile provider

Have you ever wanted Entity Framework Core to work with flat files? I do and I built a provider to help with that.

There are times where dealing with relational databases and migrations just get in the way of focusing on more important details.

I really like the in-memory provider Microsoft created for Entity Framework Core. However, its designed for testing. I've wanted to use it for iterating on prototypes and tracer bullet projects, which is hard because it doesn't save state after a process stops.

In the past, I've used the in-memory provider and overrode the Save() method for a DbContext class to save and read data from a JSON file.

This weekend, I got tired of the limited in-memory provider. I put together a concept flat file/in-memory provider for Entity Framework Core based on the in-memory provider.

The provider only uses XML. I have plans to extend that to YAML and JSON. And I may need to tweak how the provider generates Ids for the value factory generator. Once I've used the library enough, I'll publish a nuget package.

The data is loaded from a file for each initial call to a table. The provider will only update files for tables that have changes.

Instead of a database name, it requires a path to the folder where it will store each table as a flat file for the given storage format.

The code can be found NerdyMishka/src/EntityFrameworkCore.FlatFile

Here is a quick sample of how to use it from the Startup.cs file in an ASP.NET Core project:

        public IHostingEnvironment Env { get; set; }

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
            var path = this.Env.ContentRootPath.Replace("\\", "/") + "/Data/jolt9";

            services.AddDbContext<Jolt9DbContext>(o =>