Persistence in Entity Framework

There are two scenarios when persisting an entity using EntityFramework, connected and disconnected scenarios.

Connected Scenario: This is when an entity is retrieved from the database and persist is used in the same context. Context object doesn't destroy between entity retrieval and persistence of entities.

Disconnected Scenario: Disconnected scenario is when an entity is retrieved from the database and the changed entities are submitted using the different objects in the context. The following example illustrates disconnected scenario:

As per the above scenario, Context1 is used for read operation and then Context1 is destroyed. Once entities change, the application submits entities using Context2 - a different context object.

Disconnected scenario is complex because the new context doesn't know anything about the modified entity so you will have to instruct the context of what has changed in the entity. In the figure below, the application retrieves an entity graph using Context 1 and then the application performs some CUD (Create, Update, Delete) operations on it and finally, it saves the entity graph using Context 2. Context 2 doesn't know what operation has been performed on the entity graph in this scenario.

Learn how to do the CRUD operation in the connected scenario in the next section.

Entity Framework Tutorial Basics(20):Persistence in Entity Framework的更多相关文章

  1. Entity Framework Tutorial Basics(8):Types of Entity in Entity Framework

    Types of Entity in Entity Framework: We created EDM for existing database in the previous section. A ...

  2. Entity Framework Tutorial Basics(2):What is Entity Framework?

    What is Entity Framework? Writing and managing ADO.Net code for data access is a tedious and monoton ...

  3. Entity Framework Tutorial Basics(25):Delete Single Entity

    Delete Entity using DBContext in Disconnected Scenario: We used the Entry() method of DbContext to m ...

  4. Entity Framework Tutorial Basics(24):Update Single Entity

    Update Existing Entity using DBContext in Disconnected Scenario: In this chapter, you will learn how ...

  5. Entity Framework Tutorial Basics(23):Add Single Entity

    Add New Entity using DBContext in Disconnected Scenario: In this chapter you will learn how to add n ...

  6. Entity Framework Tutorial Basics(1):Introduction

    以下系列文章为Entity Framework Turial Basics系列 http://www.entityframeworktutorial.net/EntityFramework5/enti ...

  7. Entity Framework Tutorial Basics(31):Migration from EF 4.X

    Migration from Entity Framework 4.1/4.3 to Entity Framework 5.0/6.0 To migrate your existing Entity ...

  8. Entity Framework Tutorial Basics(27):Update Entity Graph

    Update Entity Graph using DbContext: Updating an entity graph in disconnected scenario is a complex ...

  9. Entity Framework Tutorial Basics(22):Disconnected Entities

    Disconnected Entities: Before we see how to perform CRUD operation on disconnected entity graph, let ...

随机推荐

  1. 非root用户 如何将cscope安装到指定目录,vim74安装

    随着Linux的普及,使用Linux进行软件开发的人也越来越多.而大多数公司都采用这种方式:提供一台高性能的中央服务器做为开发编译服务器,每个人登录这台服务器进行开发编译.在这种情况下,用户通常没有r ...

  2. UVA - 10934 Dropping water balloons (dp,逆向思维)

    题目链接 题目大意:给你n个规格一样的气球和一栋大楼的高度,求最少试验几次能测出气球最高在哪一层掉下来不破. 如果这道题想用(dp[i][j]=用i个气球测出j高度的楼需要几次)来作为状态的话,那你就 ...

  3. 2017-2018-1 20179215 第十一周 ShellShock攻击实验

    <Linux内核原理与设计>第十一周作业 ShellShock攻击实验 分组:和20179205王雅哲共同完成实验及博客攥写 实验内容:  Bash中发现了一个严重漏洞shellshock ...

  4. Nginx简介及配置介绍

    一.什么是Nginx Nginx是一个高性能的HTTP和反向代理服务器,也是一个IMAP/POP3/SMTP服务器.Nginx是由Igor Sysoev为俄罗斯访问量第二的Rambler.ru站点开发 ...

  5. PHP 判断字符的编码 并输出想要的编码格式字符 (转)

    /** * 判断字符编码  并输出想要的编码 * Enter description here ... * @param unknown_type $string * @param unknown_t ...

  6. 手机访问PC网站自动跳转到手机网站代码(转)

    4G时代,手机网站已经非常普遍了,一般手机网站都有一个二级域名来访问,比如 m.16css.com 如果手机直接访问www.16css.com 就是PC网站,在手机上浏览电脑版网站体验非常不好. 如果 ...

  7. 用Json Template在Azure上创建Cisco CSR路由器

    Azure的ARM模式可以通过Json的模板创建VM.本文以Cisco的CSR的image为例,介绍如何用Json的创建VM. 一.Cisco CSR的Image 首先把Cisco CSR的image ...

  8. mvn + idea jar包配置 错误记录

    1.创建项目方法和步骤,网上一搜一大把 2.主要出现了一个配置上的错误,java_home的配置 发现idea和eclipse有一个地方配置不同,就是java_home,在eclipse中 mvn的配 ...

  9. (转)基于PHP——简单的WSDL的创建(WSDL篇)

    本文转载自:http://blog.csdn.net/rrr4578/article/details/24451943 1.建立WSDL文件     建立WSDL的工具很多,eclipse.zends ...

  10. 【转】LTE-NAS过程学习总结

    为了从网络得到非接入层服务,网络中非接入层节点必须知道有关UE的信息.为了这个目的,UE不得不发起附属过程,该过程是在UE开机和初始接入网络时必须被执行的. 一旦该过程成功,MME上就会建立好一个该U ...