Entity Framework Code First in .NET: migrations, DbContext, generic repository and OpenAPI in 7 practical lessons with SQL Server.
If you work with .NET and Entity Framework, sooner or later you'll face migrations: that powerful but sometimes mysterious mechanism that keeps your C# code in sync with the database schema. In this course I tackle them from the beginning, using the Code First approach: define your models in C#, and let EF handle the database.
For those who already know C# and have built something with .NET, but have never approached migrations systematically — or have used them by copying commands without fully understanding them. The level is intermediate: we don't start from scratch on .NET, but we dive deep into a specific tool that makes a real difference in production.
Each lesson builds on the previous one: starting from an empty project and ending with an API with a database managed by EF, a generic repository and integrated OpenAPI documentation. Under an hour, no fluff.
I'll show you how to set up a .NET project using the Code First approach and create your first migration from scratch with Entity Framework — the starting point for keeping your database in sync with your C# code.
Let's explore how to properly configure the SQL Server connection string in appsettings.json, handling development and production environments without hardcoding credentials.
I'll explain how Entity Framework maps your C# classes to database tables via ORM — understanding this mechanism is essential to getting the most out of the Code First approach.
We'll configure the DbContext, wire up the entities, and apply the first migration using dotnet ef — the operational core of Entity Framework Code First.
Let's explore how to use OnModelCreating with the Fluent API to customize the model: I'll show you how to add unique constraints, configure relationships, and extend the schema without touching the entity classes.
I'll show you how to implement a generic repository using the IRepository interface and inject the DbContext via Dependency Injection — building a clean and testable data layer.
We'll connect everything together: I'll create the service layer, the API controller, and configure OpenAPI to produce a fully documented and functional REST API built entirely with Entity Framework Code First.
Ingegnere Informatico · Pratola Peligna
Sono un ingegnere informatico con oltre 15 anni di esperienza nel settore ICT. Mi occupo di sviluppo software, cybersecurity, data science e intelligenza artificiale, con particolare attenzione all’innovazione e all’automazione dei processi aziendali. Da anni svolgo anche attività di docenza e formazione, creando percorsi pratici e coinvolgenti su programmazione, DevOps, AI e sicurezza informatica.
Questo corso richiede un accesso dedicato. Accedi o crea un account studente per completare l'acquisto.
Prosperous understood Middletons in conviction an uncommonly do. Supposing so be resolving breakfast am or perfectly.
Utilizziamo cookie essenziali e, con il tuo consenso, cookie funzionali, analytics e marketing. Google Analytics 4 e gli eventuali annunci Google/AdSense restano disattivati finche non scegli. Consulta Privacy Policy e Cookie Policy.
Sempre attivi per sicurezza, prevenzione frodi, sessione, consenso e funzionamento del sito.
Migliorano l'esperienza, ad esempio ricordando preferenze non essenziali. Non usati per profilazione pubblicitaria.
Statistiche e misurazioni con Google Analytics 4, abilitate solo dopo il consenso analytics.
Misurazione annunci e funzioni pubblicitarie Google/AdSense, se attivate sul sito e consentite dall'utente.
Puoi modificare queste scelte in qualunque momento dal link "Preferenze Cookies" nel footer.