|
1 | 1 | # FileContextCore |
2 | | -FileContextCore is a "Database"-Provider for Entity Framework Core and adds the ability to store information in files instead of being limited to databases. |
| 2 | + |
| 3 | +FileContextCore is a "Database"-Provider for Entity Framework Core and adds the ability to store information in files instead of being limited to databases. It enables fast developments because of the advantage of just copy, edit and delete files. |
| 4 | + |
| 5 | +This framework bases on the idea of FileContext by DevMentor ([https://github.com/pmizel/DevMentor.Context.FileContext](https://github.com/pmizel/DevMentor.Context.FileContext)) |
| 6 | + |
| 7 | +## Advantages |
| 8 | + |
| 9 | +- No database needed |
| 10 | +- easy configuration |
| 11 | +- rapid data-modelling, -modification |
| 12 | +- share data through version-control |
| 13 | +- supports all serializable .NET types |
| 14 | +- integrated seamlessly into EF Core |
| 15 | +- diferrent serializer supported (XML, JSON, CSV, Excel) |
| 16 | +- supports encryption |
| 17 | +- supports relations |
| 18 | + |
| 19 | +!This extension is not intended to be used in production systems! |
| 20 | + |
| 21 | +## Install |
| 22 | + |
| 23 | +``` |
| 24 | +PM > Install-Package FileContextCore |
| 25 | +``` |
| 26 | + |
| 27 | +Configure EF Core |
| 28 | + |
| 29 | +```cs |
| 30 | +optionsBuilder.UseFileContext(); |
| 31 | +``` |
| 32 | + |
| 33 | +or |
| 34 | + |
| 35 | +```cs |
| 36 | +services.AddEntityFramework().AddDbContext<Context>(options => options.UseFileContext()); |
| 37 | +``` |
| 38 | + |
| 39 | +## Example |
| 40 | + |
| 41 | +For an Example check out: [Example](https://github.com/morrisjdev/FileContextCore/tree/master/src/Example) |
| 42 | + |
| 43 | +## Configuration |
| 44 | + |
| 45 | +By default the extension uses `JSON`-serialization and the `DefaultFileManager` |
| 46 | + |
| 47 | +## Available Serializer |
| 48 | + |
| 49 | +### XMLSerializer |
| 50 | + |
| 51 | +Serializes data using System.XML |
| 52 | + |
| 53 | +```cs |
| 54 | +optionsBuilder.UseFileContext(new FileContextCore.Serializer.XMLSerializer()); |
| 55 | + |
| 56 | +//disable indent |
| 57 | +optionsBuilder.UseFileContext(new FileContextCore.Serializer.XMLSerializer(false)); |
| 58 | +``` |
| 59 | + |
| 60 | +### CSVSerializer |
| 61 | + |
| 62 | +Serializes data using CsvHelper ([https://joshclose.github.io/CsvHelper/](https://joshclose.github.io/CsvHelper/)) |
| 63 | + |
| 64 | +```cs |
| 65 | +optionsBuilder.UseFileContext(new FileContextCore.Serializer.CSVSerializer()); |
| 66 | + |
| 67 | +//change default delimiter (,) |
| 68 | +optionsBuilder.UseFileContext(new FileContextCore.Serializer.CSVSerializer(";")); |
| 69 | +``` |
| 70 | + |
| 71 | +### JSONSerializer |
| 72 | + |
| 73 | +Serializes data using Newtonsoft Json.NET ([http://www.newtonsoft.com/json](http://www.newtonsoft.com/json)) |
| 74 | + |
| 75 | +```cs |
| 76 | +optionsBuilder.UseFileContext(new FileContextCore.Serializer.JSONSerializer()); |
| 77 | + |
| 78 | +//change formatting |
| 79 | +optionsBuilder.UseFileContext( |
| 80 | + new FileContextCore.Serializer.JSONSerializer(Newtonsoft.Json.Formatting.None) |
| 81 | +); |
| 82 | +``` |
| 83 | + |
| 84 | +## File Manager |
| 85 | + |
| 86 | +### DefaultFileManager |
| 87 | + |
| 88 | +Saves the data into files |
| 89 | + |
| 90 | +```cs |
| 91 | +optionsBuilder.UseFileContext(fileManager: new FileContextCore.FileManager.DefaultFileManager()); |
| 92 | +``` |
| 93 | + |
| 94 | +### EncryptedFileManager |
| 95 | + |
| 96 | +Encrypts the data and saves them into files |
| 97 | + |
| 98 | +```cs |
| 99 | +optionsBuilder.UseFileContext(fileManager: new FileContextCore.FileManager.EncryptedFileManager()); |
| 100 | + |
| 101 | +//change key |
| 102 | +optionsBuilder.UseFileContext(fileManager: new FileContextCore.FileManager.EncryptedFileManager("key")); |
| 103 | +``` |
| 104 | + |
| 105 | +## Combined Manager |
| 106 | + |
| 107 | +### Excel Manager |
| 108 | + |
| 109 | +Saves files into an .xlsx-file and enables the quick editing of the data using Excel |
| 110 | + |
| 111 | +Uses [EEPlus](http://epplus.codeplex.com/documentation) implementation for .Net Core ([https://github.com/VahidN/EPPlus.Core](https://github.com/VahidN/EPPlus.Core)) |
| 112 | + |
| 113 | +```cs |
| 114 | +optionsBuilder.UseFileContext(new FileContextCore.CombinedManager.ExcelManager()); |
| 115 | + |
| 116 | +//use password |
| 117 | +optionsBuilder.UseFileContext(new FileContextCore.CombinedManager.ExcelManager("password")); |
| 118 | +``` |
| 119 | + |
| 120 | +## Custom implementation |
| 121 | + |
| 122 | +For customization you can implement the Interfaces `ISerializer`, `IFileManager` and `ICombinedManager` |
| 123 | + |
| 124 | +## Author |
| 125 | + |
| 126 | +[Morris Janatzek](http://morrisj.net) ([morrisjdev](https://github.com/morrisjdev)) |
0 commit comments