1 つの方法は、EDMX に移動してフィールドの名前を AccountTypeID_Internal に変更し (たとえば)、EDMX でプロパティを に設定することPrivate
です。次に、部分クラスを作成します。
生成された Account.cs は次のようになります。
//------------------------------------------------------------------------------
// <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>
//------------------------------------------------------------------------------
namespace <yournamespace>
{
using System;
using System.Collections.Generic;
public partial class Account
{
private int AccountTypeId_Internal { get; set; }
// other auto generated properties
}
}
Account.Partial.Cs
public partial class Account : INotifyPropertyChanged
{
public Int AccountTypeId
{
get
{
return this.AccountTypeId_Internal;
}
set
{
this.AccountTypeId_Internal = value;
// Do INotifyPropertyChangedLogic
}
}
// Implement INotifyPropertyChanged
}
この利点は、既に作成されたコードをまったく変更する必要がないことです。欠点は、edmx からアカウントを削除して再度追加すると、edmx の手順を再度実行する必要があることです。