EntityBlast is a sibling in the Blast family of NuGet packages. It provides a single typed entity-store abstraction (IEntityStore<T>) backed by InMemory, JSON file, EF Core, or Dapper — pick the one you need or mix them. It also ships a runtime EF model: register types at startup via IDynamicTypeRegistry and DynamicDbContext picks them up in OnModelCreating, so you can persist types that didn't exist at compile time (for example, types produced by AssemblyBlast).
EntityBlast and AssemblyBlast are independent. Neither depends on the other. EntityBlast does not depend on UtilBlast.
IEntityStore<T>— a small async contract:Save,Insert(batch),Load,Delete,List, with composite-key overloads.- Four backends —
InMemoryEntityStore<T>,FileEntityStore<T>(JSON files in a directory),DbEntityStore<T>(EF Core),DapperEntityStore<T>(auto-creates a table from the type's properties). [IsKeyField]/[IsDisplayField]/[IsRequired]— opt-in property annotations. When[IsKeyField]is absent, key detection falls back to configurable name matches (default:Id).IDynamicTypeRegistry+DynamicDbContext— registerTypeobjects at startup; the EF context exposes aDbSet<T>for each registered type. Useful when types are emitted at runtime.IDynamicEntityResolver— resolve anIEntityStore<T>for aTypeyou only know at runtime, with an in-memory fallback if no store is registered for that type.
dotnet add package EntityBlastpublic class Person
{
[IsKeyField]
public string Id { get; set; } = "";
public string Name { get; set; } = "";
}
var store = new InMemoryEntityStore<Person>();
await store.SaveAsync("p1", new Person { Id = "p1", Name = "Ada" });
var loaded = await store.LoadAsync("p1");var keySelector = DynamicKeySelectorFactory.CreateSelector<Person>(["Id"]);
var store = new FileEntityStore<Person>("./data", keySelector);
await store.SaveAsync(new[] { "p1" }, new Person { Id = "p1", Name = "Ada" });Func<IDbConnection> open = () =>
{
var c = new SqliteConnection("Data Source=app.db");
c.Open();
return c;
};
var store = new DapperEntityStore<Person>(open, fallbackKeyNames: ["Id"]);
// CREATE TABLE IF NOT EXISTS Person (...) runs on constructionbuilder.Services.AddEntityBlast(o =>
{
o.RegisterDbStore = true;
o.ConfigureDynamicDb = db => db.UseSqlite("Data Source=app.db");
});
// Anywhere with access to IDynamicTypeRegistry:
registry.RegisterType(typeof(Person)); // or a runtime-emitted TypeMIT, see LICENSE.txt.