简体   繁体   中英

How to update existing entity framework, after adding new table in database by azure management portal

I am using VS2013 and Azure SDK 2.3, I have C# application developed in c# and DB hosted on azure cloud service, as I am new to azure I want to know that If I add any table in existing database hosted on azure through azure management portal then how I can get effect of that changes in my entity framework.

As this app is not developed fully by me so I don't know much about it's details.

For Database first approach follow below steps to achieve your task.

  1. Open your Entity Data Model Designer by clicking on your .edmx file.
    1. Right click on empty area of Entity Data model Designer.
    2. Click on Update Model From Database option.
    3. Now you left with Update Wizard, which has 3 options to Add, Refresh and delete tables.
    4. click on Add option.
    5. Choose target tables by clicking on check boxes pointing before table name.
    6. Then click on ok button, now you will see your newly added tables now.
    7. Don't forget to build your solution before performing any actions on current table.

When you add/modify some table in the production database, you have to update your application.

First thing to do is edit the web.config/app.config of the application, pointing the connection string to the production database (in your case, database in azure).

If you are using db-first, update the model from database.

If you are using code-first, it is better to make changes in your classes, and then update the database structure via data migrations. Otherwise, you might have some problems in the future updates, because the current database structure and the migration history will not match.

Update the application in the azure cloud service.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM