EntityFilesystem 4.0.3

There is a newer version of this package available.
See the version list below for details.
dotnet add package EntityFilesystem --version 4.0.3                
NuGet\Install-Package EntityFilesystem -Version 4.0.3                
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="EntityFilesystem" Version="4.0.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add EntityFilesystem --version 4.0.3                
#r "nuget: EntityFilesystem, 4.0.3"                
#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.
// Install EntityFilesystem as a Cake Addin
#addin nuget:?package=EntityFilesystem&version=4.0.3

// Install EntityFilesystem as a Cake Tool
#tool nuget:?package=EntityFilesystem&version=4.0.3                

EntityFilesystem

An EntityFramework Filesystem Provider

Adds the ability to store information in files instead of being limited to databases.

FileBaseContext is a EntityFramework Filesystem Provider for Net8+

Works for

  • Unit Test - Mocking
  • Serverless db persistance, easier than Sqlite (Tables are created for one thing)
  • Works cross platform, easy offline persistant data store

Usage

Install nuget package EntityFilesystem

PM> Install-Package Microsoft.EntityFrameworkCore
PM> Install-Package EntityFilesystem
// DbStartup.cs
using FileBaseContext.Extensions;

partial void CustomInit(DbContextOptionsBuilder optionsBuilder)
{
    optionsBuilder.UseFileBaseContextDatabase(databaseName: "DbFolderName");
}

Examples

Created with Entity Framework Visual Editor Extension from Visual Studio Marketplace

https://github.com/Opzet/EFDesignerExamples

NUGET package https://www.nuget.org/packages/EntityFilesystem

https://learn.microsoft.com/en-us/ef/core/providers/?tabs=dotnet-core-cli

Benefits

Store tables in file, easy 'Serverless' file system text file serialised ef db persistance

  • Easier than Sqlite, just works
  • you don't need a database server
  • rapid modeling
  • version control supported
  • supports all serializable .NET types
  • unit tests

Configure Provider

Powerful file based database provider for Entity Framework Core, easy 'Serverless' file system text file serialised ef db persistance

Named database
 protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    {
        optionsBuilder.UseFileBaseContextDatabase(databaseName: DatabaseName); 
    }
Custom location
optionsBuilder.UseFileBaseContextDatabase(location: "C:\Temp\userDb");

Unit testing

If you need to use the provider in unit tests, you can change IFileSystem to MockFileSystem in OnConfiguring method in datacontext class.

private readonly MockFileSystem _fileSystem;
public DbTestContext(MockFileSystem fileSystem)
{
    _fileSystem = fileSystem;
}

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
    optionsBuilder.UseFileBaseContextDatabase(DatabaseName, null, services =>
    {
        services.AddMockFileSystem(_fileSystem);
    });
}

History / Forks

File system Entity Frameworks Providers

a. FileContext by DevMentor

https://github.com/pmizel/DevMentor.Context.FileContext Core 2+

b. FileContextCore by morrisjdev

https://github.com/morrisjdev/FileContextCore Offers Different serializer supported (XML, JSON, CSV, Excel) Core 2/3 - last update Aug 2, 2020

c. FileBaseContext by dualbios

https://github.com/dualbios/FileBaseContext FileBaseContext is a provider of Entity Framework Core 8 to store database information in files. [Current developement: forked from this, adjusted namespace, tweaks, published nuget and added examples] Core 8+

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
4.0.4 0 9/21/2024
4.0.3 71 9/17/2024
4.0.2 85 9/4/2024