Entity Framework Core persistence provider for SourceFlow.Net. Provides production-ready implementations of ICommandStore, IEntityStore, and IViewModelStore using Entity Framework Core 9.0. Features include flexible configuration with separate or shared connection strings per store type, SQL Server support, Polly-based resilience and retry policies, OpenTelemetry instrumentation for database operations, and full support for .NET 8.0, .NET 9.0, and .NET 10.0. Seamlessly integrates with SourceFlow.Net core framework for complete event sourcing persistence.
$ dotnet add package SourceFlow.Stores.EntityFrameworkEntity Framework Core persistence provider for SourceFlow.Net with support for SQL Server and configurable connection strings per store type.
# Install the core package
dotnet add package SourceFlow.Net
# Install the Entity Framework provider
dotnet add package SourceFlow.Stores.EntityFramework
Add connection strings to your appsettings.json:
{
"ConnectionStrings": {
"CommandStore": "Server=localhost;Database=SourceFlowCommands;Trusted_Connection=True;",
"EntityStore": "Server=localhost;Database=SourceFlowEntities;Trusted_Connection=True;",
"ViewModelStore": "Server=localhost;Database=SourceFlowViews;Trusted_Connection=True;"
}
}
Or use a single shared connection string:
{
"ConnectionStrings": {
"DefaultConnection": "Server=localhost;Database=SourceFlow;Trusted_Connection=True;"
}
}
services.AddSourceFlowStores(configuration, options =>
{
// Use separate databases for each store
options.UseCommandStore("CommandStore");
options.UseEntityStore("EntityStore");
options.UseViewModelStore("ViewModelStore");
// Or use a single shared database
// options.UseSharedConnectionString("DefaultConnection");
});
The provider automatically creates the necessary database schema when you run your application. For production scenarios, generate and apply migrations:
dotnet ef migrations add InitialCreate --context CommandStoreContext
dotnet ef database update --context CommandStoreContextConfigure different databases for commands, entities, and view models:
services.AddSourceFlowStores(configuration, options =>
{
options.UseCommandStore("CommandStoreConnection");
options.UseEntityStore("EntityStoreConnection");
options.UseViewModelStore("ViewModelStoreConnection");
});Use a single database for all stores:
services.AddSourceFlowStores(configuration, options =>
{
options.UseSharedConnectionString("DefaultConnection");
});Apply additional EF Core configuration:
services.AddSourceFlowStores(configuration, options =>
{
options.UseCommandStore("CommandStore", dbOptions =>
{
dbOptions.EnableSensitiveDataLogging();
dbOptions.EnableDetailedErrors();
});
});The provider includes built-in Polly resilience policies for:
This project is licensed under the MIT License.