This repository contains a minimal console application demonstrating how to use Entity Framework Core with a MariaDB/MySQL database. It was created as sample code for a talk and shows basic tasks such as creating a context, seeding data and applying migrations.
https://github.com/PapeMarc/Vortrag_MicrosoftEntityFramework
- .NET 8 SDK
- MariaDB or MySQL server available on
localhost:3306 - A
config.txtfile in the project root containing the password for therootdatabase user - Optionally: dotnet-ef tools for running migrations
- Ensure the database
testexists and therootuser can access it. - Create a file named
config.txtnext to the project with only the database password as its contents. - Apply the initial migration to create the schema:
dotnet ef database update
- Run the application:
The program adds several users to the database, removes the last inserted user, saves the changes and prints all users to the console.
dotnet run
Data/AppDbContext.cs– EF Core database context and connection configuration.Model/User.cs– Simple user entity.Migrations/– Initial migration for creating theUsertable.Program.cs– Entry point demonstrating basic CRUD operations.
This project is provided as-is for demonstration purposes.