Cov txheej txheem:

Kev tsiv teb tsaws chaws yog dab tsi?
Kev tsiv teb tsaws chaws yog dab tsi?

Video: Kev tsiv teb tsaws chaws yog dab tsi?

Video: Kev tsiv teb tsaws chaws yog dab tsi?
Video: txoj kev tsiv teb tsaws chaw 2024, Kaum ib hlis
Anonim

Server tswj cov ntaub ntawv loj loj. Code migration kuj pab txhim kho kev ua tau zoo los ntawm kev siv kev sib luag. Code migration nyob rau hauv qhov dav tshaj plaws deals nrog tsiv cov kev pab cuam ntawm cov cav tov, nrog rau lub hom phiaj kom muaj cov kev pab cuam yuav raug tua ntawm lub hom phiaj. Hauv code migration lub moj khaum, ib txheej txheem muaj 3 ntu.

Nyob rau hauv no txoj kev, yog dab tsi code migration nyob rau hauv faib system?

Code Migration . Kev lig kev cai, kev sib txuas lus hauv faib systems muaj kev txhawj xeeb nrog kev sib pauv cov ntaub ntawv ntawm. txheej txheem. Code migration nyob rau hauv lub broadest kev txiav txim siab deals nrog tsiv cov kev pab cuam ntawm cov cav tov, nrog rau. lub hom phiaj kom muaj cov kev pab cuam no raug tua ntawm lub hom phiaj.

Kuj Paub, Kuv yuav ua li cas thiaj li pab tau migration hauv code ua ntej? Mus rau Package Manager Console thiab ntaus ntawv pab kev tsiv teb tsaws chaw . Hom Pab - Kev tsiv teb tsaws chaw -ContextTypeName EXPShopContext. Cov lus txib no tsim ib kev tsiv teb tsaws chaw folder nrog InitialCreate. cs thiab Configuration.

Hais txog qhov no, code thawj migration yog dab tsi?

Entity Framework 4.3 suav nrog qhov tshiab Code Thawj Migrations feature uas tso cai rau koj mus incrementally evolve lub database schema raws li koj tus qauv hloov lub sij hawm. Nrog kev tsiv teb tsaws chaw , nws yuav cia li hloov kho cov txheej txheem database, thaum koj tus qauv hloov pauv yam tsis tau poob cov ntaub ntawv uas twb muaj lawm lossis lwm yam khoom siv database.

Kuv yuav rho tawm code migration ua ntej li cas?

Hauv kev xaus, cov kauj ruam los ua qhov no yog:

  1. Tshem tawm _MigrationHistory rooj los ntawm Database.
  2. Tshem tawm cov ntaub ntawv tsiv teb tsaws chaw nyob hauv koj qhov project's Migrations folder.
  3. Qhib-Migrations nyob rau hauv pob Manager Console.
  4. Ntxiv-migration Initial hauv PMC.
  5. Tawm tswv yim tawm cov cai sab hauv ntawm Txoj Kev Up hauv Qhov Kev Nkag Tebchaws Pib.

Pom zoo: