我正在玩Entity Framework 4.3,所以我使用DbContext Generator来创建上下文和实体类.
使用默认的EF 4代码生成器模板,实体类实现INotifyPropertyChanged,还可以在属性设置器中添加Changing和Changed部分方法.
当我使用EF 4.x DbContext生成器时,如下图所示,实体类更轻,并且不包括任何跟踪属性更改的方法.

这是一个例子:
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated from a template.
//
// Manual changes to this file may cause unexpected behavior in your application.
// Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
namespace SomeNamespace
{
public partial class SomeTable
{
public SomeTable()
{
this.Children = new HashSet<Child>();
}
public long parent_id { …Run Code Online (Sandbox Code Playgroud)