简体   繁体   English

通过Azure管理门户在数据库中添加新表之后如何更新现有实体框架

[英]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. 我正在使用VS2013和Azure SDK 2.3,我已经用c#开发了C#应用程序,并且将数据库托管在azure云服务上,因为对于azure来说我是新手,所以我想知道,如果我通过azure管理门户在azure上托管的现有数据库中添加任何表,那么我如何才能在实体框架中获得这种改变的效果。

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. 通过单击.edmx文件,打开您的实体数据模型设计器。
    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. 现在,您剩下“更新向导”了,该向导具有3个用于添加,刷新和删除表的选项。
    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). 首先要做的是编辑应用程序的web.config / app.config,将连接字符串指向生产数据库(在您的情况下为Azure数据库)。

If you are using db-first, update the model from database. 如果您使用db-first,请从数据库更新模型。

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. 更新Azure云服务中的应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将新表添加到数据库后如何更新 Entity Framework Core - How to update Entity Framework Core after adding a new table to the database 在 Entity Framework Core 中使用 Update-Database 添加新列 - Adding new column using Update-Database in Entity Framework Core 使用实体框架7添加新迁移时,表未添加到数据库 - Table not added to database when adding a new migration using entity framework 7 使用实体框架在创建新实体时向数据库中的现有表添加新记录 - Add a new record to existing table in the database on a new entity creation using Entity Framework 将不带键的现有表添加到实体框架模型 - Adding an existing table with no Key to an Entity Framework model 如何在现有的远程数据库中添加表并将其链接到Entity Framework模型? - How to add table in existing remote database and link it to Entity Framework model? 在 EF Core 中添加新实体后如何更新实体 - How update entity after adding new entity in EF Core 使用实体框架向现有数据库添加或更新数据 - Add or update data to existing database with entity framework 实体框架多个上下文和Microsoft Azure。 如何更新数据库? - Entity Framework multiple context and Microsoft Azure. How to update database? USER使用Entity Framework将新角色更新到数据库中 - USER Update with new role into database with Entity Framework
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM