Skip to content

Category archive for: Entity Framework

Enabling Cascade Delete in EF Core Code First DB Using the Fluent API

Entity Framework Core Default Behaviour on Delete Cascade delete saves a developer time by not needing to write boilerplate code for related data when the parent data in the relationship has been deleted. However in Entity Framework Core it is not the default behaviour. It takes a more conservative view and sets the on delete behaviour to restrict (StackOverflow Question where EF Core Team Member Confirms) which the documentation defines as: Restrict: The delete operation is not applied to dependent entities. The dependent entities remain unchanged. – EF Core Documentation Compared with the definition of cascade: Cascade: Dependent entities are also deleted. – EF Core Documentation Enabling Cascade Delete Using The Fluent…

Continue reading Enabling Cascade Delete in EF Core Code First DB Using the Fluent API

Setting Up SQLite and Entity Framework Core in ASP.Net Core

For small applications such as prototypes and small side projects SQLite is a great choice for a relational database. It is really easy to setup because: Its self contained Its just one database file in your project. No server Because its just one database file in your project which holds all your data there is no extra server setup. No configuration All you need is to create your schema and your ready to store data. Letting Entity Framework Core Manage Your Database Schema For all its ease to setup you still need a schema to define your tables and the relationships between them. Unless your…

Continue reading Setting Up SQLite and Entity Framework Core in ASP.Net Core