简体   繁体   English

如何比较实体框架中具有相同表名的两个模型之间的数据?

[英]How to compare the data between two models that have the same tables name in Entity Framework?

Assume you have 2 databases scripts ( Source & Destination ) with the same structure and different data.假设您有 2 个具有相同结构和不同数据的数据库脚本( Source & Destination )。

This is the source database:这是数据库:

https://drive.google.com/file/d/1psVbVdJz7PbH2KXkqw1S3CkIviynIba8/view?usp=sharing https://drive.google.com/file/d/1psVbVdJz7PbH2KXkqw1S3CkIviynIba8/view?usp=sharing

And this is the destination database:这是目标数据库:

https://drive.google.com/file/d/1EvyFqpQ_meEXOyYmoUKuZHfINEFfAN--/view?usp=sharing https://drive.google.com/file/d/1EvyFqpQ_meEXOyYmoUKuZHfINEFfAN--/view?usp=sharing

  1. Load data from Source Database从源数据库加载数据
  2. Compare the data from source database to the destination database.将源数据库中的数据与目标数据库中的数据进行比较。
  3. Depending on the comparison show result in one of four groups:根据比较显示结果在四组之一:
    • Data already exist with no change.数据已经存在,没有变化。
    • New data ready to be moved.准备移动的新数据。
    • Data to be updated.要更新的数据。
    • Data to be deleted要删除的数据
  4. Then I can deploy the changes to the destination Database.然后我可以将更改部署到目标数据库。

Can anyone help me to solve this task?谁能帮我解决这个任务?

Method 1:方法一:

  1. Introduce inert, delete update triggers for SOURCE DB tables为 SOURCE 数据库表引入惰性、删除更新触发器
    • Save changes in Log table(new table)保存日志表中的更改(新表)
  2. Create stored procedure to read log table and update destination DB创建存储过程以读取日志表并更新目标数据库
  3. Call this new SP in schedule time via SQL jobs通过 SQL 作业在预定时间调用这个新的 SP

Method 2:方法二:

  1. Replicate source db in order to sync changes to destination.复制源数据库以将更改同步到目标。

暂无
暂无

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

相关问题 实体框架如何在两个表的两列之间建立关系 - Entity Framework How to have relationship between two columns of two tables 实体框架表和sql表没有相同的数据吗? - Entity framework tables and sql tables does not have the same data? 如何使用实体框架处理表单数据并提取两个不同模型/表的属性 - How do process form data and extract properties for two different models/tables using Entity Framework 实体框架4.1两个具有相同属性名称的表 - entity framework 4.1 two tables with the same property name 比较实体框架模型 - compare entity framework models 如何在实体框架中具有相同模式的多个表? - How to have multiple tables with the same schema in Entity Framework? 如何使用实体框架在WPF c#中的两个表之间插​​入一对多关系的数据? - How to insert data for one to many relationship between two tables in WPF c# using Entity Framework? 在ASP.net MVC中使用Entity Framework创建模型时,如何在单个视图中从两个表中调用数据 - How to call data from two tables in a single View when created models with Entity Framework in ASP.net MVC 如何在 Entity Framework Core 中处理两个表之间的多个关系? - How to handle multiple relationships between two tables in Entity Framework Core? 如何将相同 class 的两个列表拆分为实体框架中的不同表? - How to split two lists of the same class to different tables in Entity Framework?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM