![]() |
VOOZH | about |
dotnet add package FileContextCore --version 3.4.0
NuGet\Install-Package FileContextCore -Version 3.4.0
<PackageReference Include="FileContextCore" Version="3.4.0" />
<PackageVersion Include="FileContextCore" Version="3.4.0" />Directory.Packages.props
<PackageReference Include="FileContextCore" />Project file
paket add FileContextCore --version 3.4.0
#r "nuget: FileContextCore, 3.4.0"
#:package FileContextCore@3.4.0
#addin nuget:?package=FileContextCore&version=3.4.0Install as a Cake Addin
#tool nuget:?package=FileContextCore&version=3.4.0Install as a Cake Tool
FileContextCore is a "Database"-Provider for Entity Framework Core and adds the ability to store information in files. It enables fast developments because of the advantage of just copy, edit and delete files.
This framework bases on the idea of FileContext by DevMentor (https://github.com/pmizel/DevMentor.Context.FileContext)
!This extension is not intended to be used in production systems!
https://www.nuget.org/packages/FileContextCore/
PM > Install-Package FileContextCore
In your Startup.cs use this:
public void ConfigureServices(IServiceCollection services)
{
...
services.AddDbContext<Context>(options => options.UseFileContextDatabase());
...
}
OnConfiguring methodYou can also override the OnConfiguring method of your DbContext to apply the settings:
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseFileContextDatabase();
}
For a simple example check out: Example
You can also play around with this example on dotnetfiddle.net: Demo
By default the extension uses JSON-serialization and the DefaultFileManager
You can use a different serializer to support other serialization methods.
Serializes data using System.XML
optionsBuilder.UseFileContextDatabase<XMLSerializer, DefaultFileManager>();
Serializes data using CsvHelper (https://joshclose.github.io/CsvHelper/)
optionsBuilder.UseFileContextDatabase<CSVSerializer, DefaultFileManager>();
Serializes data using Newtonsoft Json.NET (http://www.newtonsoft.com/json)
optionsBuilder.UseFileContextDatabase<JSONSerializer, DefaultFileManager>();
or just
optionsBuilder.UseFileContextDatabase();
Serializes data to bson using Newtonsoft Json.NET (http://www.newtonsoft.com/json)
optionsBuilder.UseFileContextDatabase<BSONSerializer, DefaultFileManager>();
Saves files into an .xlsx-file and enables the quick editing of the data using Excel
Uses EEPlus implementation for .Net Core (https://github.com/VahidN/EPPlus.Core)
optionsBuilder.UseFileContextDatabase<EXCELStoreManager>();
If you want to secure the excel file with a password use:
optionsBuilder.UseFileContextDatabase<EXCELStoreManager>(password: "<password>");
To run on Linux-Systems
sudo apt-get update
sudo apt-get install libgdiplus
The file manager controls how the files are stored.
The default file manager just creates normal files.
optionsBuilder.UseFileContextDatabase<JSONSerializer, DefaultFileManager>();
The encrypted file manager encrypts the files with a password.
optionsBuilder.UseFileContextDatabase<JSONSerializer, EncryptedFileManager>(password: "<password>");
By default the files are stored in a subfolder of your running application called appdata.
If you want to control this behavior you can also use define a custom location.
optionsBuilder.UseFileContextDatabase(location: @"C:\Users\mjanatzek\Documents\Projects\test");
If noting is configured all files of your application will be stored in a flat folder. You can optionally define a name for your database and all the corresponding data will saved in a subfolder. So you are able to use FileContext with multiple DbContext-configurations.
optionsBuilder.UseFileContextDatabase(databasename: "database");
You can create custom serializer, file manager and store manager if you want.
If you want to create a custom serializer implement the interface ISerializer.
If you want to control storing of data implement interface IFileManager.
If you want to create a store manager that does both implement IStoreManager.
After adding a custom provider you have to add it as a transient dependency in the dependency injection.
Feel free to create a PR with your new provider and I'll add it to FileContextCore.
| FileContext Version | EF Core Version |
|---|---|
| 3.4.* | 3.1.0 |
| 3.3.* | 3.0.0 |
| 3.2.* | 3.0.0 |
| 3.0.1/3.0.0/2.2.6 | 2.2.6 |
| 2.2.0 | 2.2.0 |
It seems that EF Core currently does not support to define a custom table name using annotations on models.
Use the OnModelCreating-method to define a custom table name.
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<User>()
.ToTable("custom_user_table");
}
This will store the data in a file called custom_user_table.json for example.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 5 NuGet packages that depend on FileContextCore:
| Package | Downloads |
|---|---|
|
EDennis.NetCoreTestingUtilities
Provides various classes that assist with .NET Core 3 unit testing. |
|
|
RealtimeDatabase
A .NET Core Extension for Entity Framework Core to enable Realtime Capability. |
|
|
AvantiPoint.MobileAuth
The MobileAuth Library is designed to quickly stand up an OAuth endpoint for Apple, Google, & Microsoft providers with the flexibility of customizing additional ones or only providing ones that you provide a configuration for. This makes it easy to stand up a minimal API with only a few lines of code. |
|
|
Gtt.Uc.EntityFramework
Package Description |
|
|
FileContextCore.AzureBlobStorageFileManager
Azure blob storage implementation for the File Context Core package. It allows to use EntityFramework Core without a database, just using a file located in an Azure blob storage as database |
Showing the top 2 popular GitHub repositories that depend on FileContextCore:
| Repository | Stars |
|---|---|
|
SapphireDb/SapphireDb
SapphireDb Server, a self-hosted, easy to use realtime database for Asp.Net Core and EF Core
|
|
|
mguinness/IdentityManagerUI
Identity management system for ASP.NET Core Identity.
|
| Version | Downloads | Last Updated |
|---|---|---|
| 3.4.0 | 53,216 | 6/7/2020 |
| 3.3.0 | 2,387 | 3/19/2020 |
| 3.2.3 | 1,278 | 3/18/2020 |
| 3.2.2 | 19,247 | 11/1/2019 |
| 3.2.1 | 1,320 | 11/1/2019 |
| 3.2.0 | 1,328 | 10/30/2019 |
| 3.0.1 | 1,447 | 10/29/2019 |
| 3.0.0 | 2,302 | 8/23/2019 |
| 2.2.6 | 1,510 | 8/7/2019 |
| 2.2.0 | 1,708 | 1/3/2019 |
| 2.1.4 | 1,684 | 10/26/2018 |
| 2.1.0 | 2,354 | 6/22/2018 |
| 2.0.1 | 2,587 | 1/13/2018 |
| 1.0.9 | 2,477 | 7/2/2017 |
| 1.0.8 | 2,336 | 5/27/2017 |
| 1.0.7 | 2,394 | 3/28/2017 |
| 1.0.6 | 2,375 | 3/25/2017 |
| 1.0.5 | 2,606 | 3/25/2017 |
| 1.0.4 | 2,418 | 3/24/2017 |
| 1.0.3 | 2,545 | 3/24/2017 |