EnsureCreated
EnsureCreated is an Entity Framework Core method that creates a database and its schema if they do not exist, without applying migrations.
ASP.NET Core in Action, 3e
EnsureCreated is an Entity Framework Core database method that creates the database and its schema if they do not already exist, without applying migrations.
- How it is used
- Prepares SQLite in-memory databases for EF Core tests that need fast creation, isolation, and teardown.
- How deep it goes
- Explains database creation, migration compatibility, connection lifetime, and a complete test setup, but not schema-generation internals.
- Examples
- Uses a RecipeService test with an in-memory SQLite connection, AppDbContext, EnsureCreated(), and seeded recipe entities.
- What you can do after
- Apply it via EF Core to prepare an isolated SQLite in-memory database for tests.
Read how ASP.NET Core in Action, 3e explains EnsureCreated →
Building Distributed Applications that Work
EnsureCreated is an Entity Framework method that creates the database if it does not already exist.
- How it is used
- Creates the products database during API startup when it does not already exist.
- How deep it goes
- Defines automatic creation when the database is absent and stops short of customized setup such as collation.
- Examples
- Shows EnsureCreated() before checking whether the Products set contains rows.
- What you can do after
- Apply it through Entity Framework to create a missing database with default configuration.
Read how Building Distributed Applications that Work explains EnsureCreated →
Related concepts
- database migrationcontrasts with · A database migration is a controlled change to a database schema or its associated structures as application requirements evolve.
- migrationcontrasts with · A migration is a process of transferring or transforming data, software, or system state from a source form or environment to a target form or environment.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

