Added. The entity does not yet exist in the database. The SaveChanges method must issue an INSERT statement.
Unchanged. Nothing needs to be done with this entity by the SaveChanges method. When you read an entity from the database, the entity starts out with this status.
Modified. Some or all of the entity's property values have been modified. The SaveChanges method must issue an UPDATE statement.
Deleted. The entity has been marked for deletion. The SaveChanges method must issue a DELETE statement.
Detached. The entity isn't being tracked by the database context.(分离状态:实体没有被数据上下文跟踪)

Entity states让SaveChanges()方法可以确定命令内容
For example, when you pass a new entity to the Add method, that entity's state is set to Added. Then when you call the SaveChanges method, the database context issues a SQL INSERT command.

Entity States的更多相关文章

  1. EF4.1: Add/Attach and Entity States(EF中的实体状态转换说明)

    实体的状态,连接以及 SaveChanges 方法 数据库上下文对象维护内存中的对象与数据库中数据行之间的同步.这些信息在调用 SaveChanges方法被调用的时候使用.例如,当使用 Add 方法传 ...

  2. 实体生命周期【Entity Lifecycle】(EF基础系列10)

    Before we work on CRUD operation (Create, Read, Update, Delete), it's important to understand the en ...

  3. ASP.NET MVC with Entity Framework and CSS一书翻译系列文章之第六章:管理产品图片——多对多关系(上篇)

    在这章中,我们将学习如何创建一个管理图片的新实体,如何使用HTML表单上传图片文件,并使用多对多关系将它们和产品关联起来,如何将图片存储在文件系统中.在这章中,我们还会学习更加复杂的异常处理,如何向模 ...

  4. Entity Framework Code First - Change Tracking

    In this post we will be discussing about change tracking feature of Entity Framework Code First. Cha ...

  5. Entity Framework Tutorial Basics(10):Entity Lifecycle

    Entity Lifecycle: Before we work on CRUD operation (Create, Read, Update, Delete), it's important to ...

  6. Entity Framework Tutorial Basics(7):DBContext

    DBContext: As you have seen in the previous Create Entity Data Model section, EDM generates the Scho ...

  7. 数据上下文【 DnContext】【EF基础系列7】

    DBContext: As you have seen in the previous Create Entity Data Model section, EDM generates the Scho ...

  8. 【记录】EF Code First 实体关联,如何添加、修改实体?

    在使用 EF Code First 的时候,我们经常会对项目中的 Entry 进行一对多.多对多的映射配置,这时候就会产生主实体和子实体的概念,我们在添加.修改他们的时候,有时候会产生一些问题,比如添 ...

  9. [渣译文] 使用 MVC 5 的 EF6 Code First 入门 系列:实现基本的CRUD功能

    英文渣水平,大伙凑合着看吧…… 这是微软官方SignalR 2.0教程Getting Started with Entity Framework 6 Code First using MVC 5 系列 ...

随机推荐

  1. Delphi 获取Internet缓存文件 -- FindFirstUrlCacheEntry FindNextUrlCacheEntry

    下面是我写的一个函数,把所有的缓存文件路径添加到一个字符串列表中,直接看代码,带了注释.另外还有删除缓存等等大家自己到msdn找找. 需要引用 WinInet // 获取Internet缓存文件 fu ...

  2. css3-7 如何让页面元素水平垂直都居中(元素定位要用css定位属性)

    css3-7 如何让页面元素水平垂直都居中(元素定位要用css定位属性) 一.总结 一句话总结:元素定位要用css定位属性,而且一般脱离文档流更加好操作.先设置为绝对定位,上左都50%,然后margi ...

  3. http各种状态码具体解释

    1XX (暂时响应)   100(继续) 请求者应当继续提出请求.   101(切换协议)请求者已要求server切换协议,server已确认并准备切换 2XX(成功)    ·200(成功) ser ...

  4. Java实现的并发任务处理实例

    本文实例讲述了Java实现的并发任务处理方法.分享给大家供大家参考,具体如下: public void init() { super.init(); this.ioThreadPool = new T ...

  5. [Angular] Content Projection with ng-content

    For example there is tow form compoennts on the page, and what we want to do is reusing the form com ...

  6. HDU 1502 - dp + 压位

    传送门 题目大意: 3*n的字符串,A.B.C分别有n个,w(X)代表X字母出现的次数,要求该字符串的所有前缀中w(A) >= w(B) >= w(C),问合法方案数有多少. 题目分析: ...

  7. 【t095】拯救小tim

    Time Limit: 1 second Memory Limit: 128 MB [问题描述] 小tim在游乐场,有一天终于逃了出来!但是不小心又被游乐场的工作人员发现了... 所以你的任务是安全地 ...

  8. sparksql 用反射的方式将rdd转换成dataset/dataframe

    java public class ReflectionDemo { private static SparkConf conf = new SparkConf().setAppName(" ...

  9. request.getSession().getServletContext().getRealPath()的一些坑

    今天是学校机房的服务器上对之前的一个网站升级时发现了一个bug,我自己的机器上用的tomcat8,机房上是tomcat7,结果一运行就开始报找不到文件,最后发现是文件分隔符的问题 原来在代码中涉及到路 ...

  10. MFC下WM_NOTIFY消息处理流程

    参考文章:MFC的消息反射机制 在前一篇文章:MFC消息处理流程概述中描述了MFC消息处理的大体流程.由CWnd::OnWndMsg函数可知,当消息为WM_NOTIFY消息时,调用的是virtual ...