Kuv yuav rov qab tsiv teb tsaws chaw li cas hauv Entity Framework Core?
Kuv yuav rov qab tsiv teb tsaws chaw li cas hauv Entity Framework Core?

Video: Kuv yuav rov qab tsiv teb tsaws chaw li cas hauv Entity Framework Core?

Video: Kuv yuav rov qab tsiv teb tsaws chaw li cas hauv Entity Framework Core?
Video: kheev lam sij hawm tig tau rov qab 10/23/2018 2024, Kaum ib hlis
Anonim

Rau rov qab los zaum kawg thov kev tsiv teb tsaws chaw koj yuav tsum (tus thawj tswj pob console commands): Rov qab tsiv teb tsaws chaw los ntawm database: PM> Hloov tshiab-Databas

kev tsiv teb tsaws chaw-name> Tshem tawm kev tsiv teb tsaws chaw cov ntaub ntawv los ntawm qhov project (los yog nws yuav rov qab siv dua rau cov kauj ruam tom ntej) Hloov tshiab qauv snapshot: PM> Tshem tawm- Kev tsiv teb tsaws chaw.

Yog li ntawd, kuv yuav ua li cas tshem tawm kev tsiv teb tsaws chaw hauv Entity Framework?

Hauv EF Core koj tuaj yeem nkag mus rau qhov hais kom tshem tawm- Kev tsiv teb tsaws chaw hauv pob tus thawj tswj console tom qab koj tau ntxiv koj qhov yuam kev kev tsiv teb tsaws chaw . Ib qho haujlwm tau scaffolded uas yuav ua rau poob ntawm cov ntaub ntawv. Thov tshuaj xyuas qhov kev tsiv teb tsaws chaw rau qhov raug. Rau thim rov qab qhov kev txiav txim no, siv Remove- Kev tsiv teb tsaws chaw.

Qhov thib ob, Kuv yuav hloov kho kuv Qhov Chaw Ua Haujlwm Li Cas Core? Txhawm rau hloov kho qhov chaw nrog Entity Framework Core, qhov no yog cov txheej txheem tsim nyog:

  1. Tsim piv txwv rau chav kawm DbContext.
  2. Retrieve entity los ntawm qhov tseem ceeb.
  3. Ua cov kev hloov ntawm qhov chaw cov khoom.
  4. Txuag kev hloov.

Yog li ntawd, kuv yuav tsiv mus nyob rau hauv Entity Framework li cas?

Hauv qab no yog cov ntsiab lus hauv chav kawm. Kauj ruam 1 - Ua ntej khiav daim ntawv thov koj yuav tsum tau pab kev tsiv teb tsaws chaw . Kauj ruam 2 - Qhib Pob Tus Thawj Tswj Console los ntawm Cov Cuab Yeej → NuGet Package Manger → Pob Manger Console. Kauj ruam 3 - Kev tsiv teb tsaws chaw twb enabled, tam sim no ntxiv kev tsiv teb tsaws chaw hauv koj daim ntawv thov los ntawm kev ua raws li cov lus txib hauv qab no.

Kev tsiv teb tsaws chaw hauv. NET core yog dab tsi?

Kev tsiv teb tsaws chaw yog ib txoj hauv kev kom cov database schema sync nrog EF Core qauv los ntawm kev khaws cov ntaub ntawv. EF Core migrations yog ib txheej ntawm cov lus txib uas koj tuaj yeem ua tiav hauv NuGet Package Manager Console lossis hauv dotnet Command Line Interface (CLI).

Pom zoo: