EntityFilesystem 4.0.3
See the version list below for details.
dotnet add package EntityFilesystem --version 4.0.3
NuGet\Install-Package EntityFilesystem -Version 4.0.3
<PackageReference Include="EntityFilesystem" Version="4.0.3" />
paket add EntityFilesystem --version 4.0.3
#r "nuget: EntityFilesystem, 4.0.3"
// 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
- Ex1_ModelPerson
- Ex2_ModelOne2One
- Ex3_ModelOnetoMany
- Ex4_ModeManytoMany
- Ex5_ModelInvoice
- Ex6_Course
- Ex7_Mvp
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 | Versions 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. |
-
net8.0
- Microsoft.EntityFrameworkCore (>= 8.0.8)
- Microsoft.EntityFrameworkCore.Relational (>= 8.0.8)
- System.IO.Abstractions.TestingHelpers (>= 21.0.29)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.