EF Core

Packages

 Microsoft.EntityFrameworkCore.Design:

- scaffolding

- migrations

- reverse engineering


Microsoft.EntityFrameworkCore.Tools:

- command-line tooling support voor Package Manager Console (PMC)

    - Add-Migration

    - Update-Database

    - Remove-Migration

    - Scaffold-DbContext

    - Drop-Database

    - Script-Migration

Commands

PMC:

- Migration aanmaken

    Add-Migration TheNameOfTheMigration --> creates a migration cs file in the Migrations folder


- Database bijwerken

    Update-Database

----

After modifying the (domain) model, you need to create a new migration (so the DB will also be updated):

    Add-Migration DescriptionOfTheModification


Next update the database again:

    Update-Database

----

After each time Add-migration is run, EFCore automatically creates a Snapshot file, also located in the Migrations folder.

Working of the Change tracker

https://www.youtube.com/watch?v=NWL_W2m69SM

Summary:

- Tracked entities are synced via PK's & FK's

- Add() or Updates() recursively add entities to the change tracker

- SaveChanges only use ChangeTracker to modify the database

- ChangeTracker is basically just a list with entities and their state 

Reacties

Populaire posts van deze blog

IIS: Application pool recycling vs IIS Reset

Hoofdstuk 2 - Les 2

Totstandkoming estimated en actual query plans Sql Server