Toggly.FeatureManagement.Storage.EntityFramework
3.2.3
See the version list below for details.
dotnet add package Toggly.FeatureManagement.Storage.EntityFramework --version 3.2.3
NuGet\Install-Package Toggly.FeatureManagement.Storage.EntityFramework -Version 3.2.3
<PackageReference Include="Toggly.FeatureManagement.Storage.EntityFramework" Version="3.2.3" />
<PackageVersion Include="Toggly.FeatureManagement.Storage.EntityFramework" Version="3.2.3" />
<PackageReference Include="Toggly.FeatureManagement.Storage.EntityFramework" />
paket add Toggly.FeatureManagement.Storage.EntityFramework --version 3.2.3
#r "nuget: Toggly.FeatureManagement.Storage.EntityFramework, 3.2.3"
#:package Toggly.FeatureManagement.Storage.EntityFramework@3.2.3
#addin nuget:?package=Toggly.FeatureManagement.Storage.EntityFramework&version=3.2.3
#tool nuget:?package=Toggly.FeatureManagement.Storage.EntityFramework&version=3.2.3
Toggly Entity Framework Snapshot Provider
Entity Framework Core snapshot provider for Toggly Feature Management. Stores feature flag snapshots in any database supported by Entity Framework Core (SQL Server, PostgreSQL, MySQL, SQLite, etc.).
Installation
dotnet add package Toggly.FeatureManagement.Storage.EntityFramework
You'll also need to install the appropriate EF Core database provider for your database:
# SQL Server
dotnet add package Microsoft.EntityFrameworkCore.SqlServer
# PostgreSQL
dotnet add package Npgsql.EntityFrameworkCore.PostgreSQL
# MySQL
dotnet add package Pomelo.EntityFrameworkCore.MySql
# SQLite
dotnet add package Microsoft.EntityFrameworkCore.Sqlite
Usage
Basic Setup
using Toggly.FeatureManagement.Storage.EntityFramework.Configuration;
// In Program.cs or Startup.cs
services.AddTogglyEntityFrameworkSnapshotProvider(
options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))
);
// Then configure Toggly as usual
services.AddTogglyFeatureManagement(options => {
options.AppKey = "your-app-key";
options.Environment = "production";
});
With Custom Settings
services.AddTogglyEntityFrameworkSnapshotProvider(
options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")),
settings => {
settings.DocumentName = "my_features"; // Default: "toggly_features"
settings.JwkDocumentName = "my_jwks"; // Default: "toggly_jwks"
settings.AutoCreateTable = true; // Default: true
}
);
With Existing DbContext Registration
If you've already registered TogglyEntities in your DI container:
// Register the DbContext separately
services.AddDbContext<TogglyEntities>(options =>
options.UseNpgsql(Configuration.GetConnectionString("PostgresConnection"))
);
// Then just add the snapshot provider
services.AddTogglyEntityFrameworkSnapshotProvider();
Database Examples
SQL Server
services.AddTogglyEntityFrameworkSnapshotProvider(
options => options.UseSqlServer("Server=localhost;Database=MyApp;Trusted_Connection=True;")
);
PostgreSQL
services.AddTogglyEntityFrameworkSnapshotProvider(
options => options.UseNpgsql("Host=localhost;Database=myapp;Username=user;Password=pass")
);
SQLite
services.AddTogglyEntityFrameworkSnapshotProvider(
options => options.UseSqlite("Data Source=toggly.db")
);
MySQL
services.AddTogglyEntityFrameworkSnapshotProvider(
options => options.UseMySql(
"Server=localhost;Database=myapp;User=user;Password=pass;",
ServerVersion.AutoDetect(connectionString)
)
);
Table Schema
The provider creates a single table TogglySnapshots with the following schema:
| Column | Type | Description |
|---|---|---|
| Id | VARCHAR(100) | Primary key (document name) |
| Data | TEXT | JSON serialized snapshot data |
| Signature | VARCHAR(1000) | Signature for signed definitions |
| KeyId | VARCHAR(100) | Key ID for signature verification |
| Timestamp | BIGINT | Unix timestamp of the snapshot |
| UpdatedAt | DATETIME | Last update time |
Auto Table Creation
By default, the provider will automatically create the table if it doesn't exist when AutoCreateTable is set to true (default).
If you prefer to manage database schema yourself, set AutoCreateTable = false and run the appropriate migration:
-- SQL Server
CREATE TABLE TogglySnapshots (
Id NVARCHAR(100) NOT NULL PRIMARY KEY,
Data NVARCHAR(MAX) NOT NULL,
Signature NVARCHAR(1000) NULL,
KeyId NVARCHAR(100) NULL,
Timestamp BIGINT NULL,
UpdatedAt DATETIME2 NOT NULL
);
-- PostgreSQL
CREATE TABLE "TogglySnapshots" (
"Id" VARCHAR(100) NOT NULL PRIMARY KEY,
"Data" TEXT NOT NULL,
"Signature" VARCHAR(1000) NULL,
"KeyId" VARCHAR(100) NULL,
"Timestamp" BIGINT NULL,
"UpdatedAt" TIMESTAMP NOT NULL
);
Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
| DocumentName | string | "toggly_features" | ID for the feature snapshot document |
| JwkDocumentName | string | "toggly_jwks" | ID for the JWK snapshot document |
| AutoCreateTable | bool | true | Automatically create table if it doesn't exist |
Related Packages
- Toggly.FeatureManagement - Core feature management library
- Toggly.FeatureManagement.Storage.RavenDB - RavenDB snapshot provider
- Toggly.FeatureManagement.Storage.DistributedCache - Distributed cache snapshot provider
License
MIT License - see LICENSE for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. 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. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.EntityFrameworkCore (>= 10.0.0-preview.1.25081.2)
- Microsoft.EntityFrameworkCore.Relational (>= 10.0.0-preview.1.25081.2)
- Toggly.FeatureManagement (>= 3.2.3)
-
net6.0
- Microsoft.EntityFrameworkCore (>= 6.0.4)
- Microsoft.EntityFrameworkCore.Relational (>= 6.0.4)
- Toggly.FeatureManagement (>= 3.2.3)
-
net8.0
- Microsoft.EntityFrameworkCore (>= 8.0.0)
- Microsoft.EntityFrameworkCore.Relational (>= 8.0.0)
- Toggly.FeatureManagement (>= 3.2.3)
-
net9.0
- Microsoft.EntityFrameworkCore (>= 9.0.0)
- Microsoft.EntityFrameworkCore.Relational (>= 9.0.0)
- Toggly.FeatureManagement (>= 3.2.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.