How to update models in VS 2019 from database in Entity Framework in ASP.NET Core

后端 未结 3 1929
予麋鹿
予麋鹿 2021-01-07 04:45

By VS 2019, I created an API project (database first), everything it\'s working well, now I made some changes in the database like add new tables and some property and modif

3条回答
  •  春和景丽
    2021-01-07 04:46

    Hi I am Considering you are using EFCore, please confirm !! 
    As per available information over internet 
    EF core for DB first ( from db to EF ) approach to Modify new/existing entity 
    

    you need to follow steps as:

    1. EF model require to run Scaffold with flag Force

    EF model require to run Scaffold with flag Force this will remove all your local changes in model (for me it was IdentityDBContext and override identityUser changes)


    1. after run the all your model migration

    2. running all migration will bring everything in sync bw EF and DB


    now you need to do the local changaes again over solution ( for me update IdentityDBContext and override identityUser changes back as it was before db changes )


    1. also as per below answer please notice EDMX object is not available yet, anyone has any clue then please share here.

提交回复
热议问题