EF 5以降のデータ注釈に関する新しい機能があるかどうか疑問に思っています。私はデータベース ファーストを行っているので、私の知る限り、常に T4 を操作する必要があります。これは、EF バージョンの MS ごとにデフォルトの T4 が変更されるため、非常に面倒です。そのようなものに代わるものがあれば、誰かが教えてくれますか:
操作された T4:
<#=codeStringGenerator.UsingDirectives(inHeader: false, includeAnnotations: true)#>
[MetadataType(typeof(<#=code.Escape(entity)#>Metadata))]
<#=codeStringGenerator.EntityClassOpening(entity)#>
クラスの名前が「Address」の場合の結果のクラス サンプル:
[MetadataType(typeof(AddressMetadata))]
public partial class Address
{
生成された「Address」クラスと同じ名前空間内の注釈用の追加クラス:
public class AddressMetadata
{
[Display(Name = "Straße")]
public string Street;
[Display(Name = "Land")]
public string Country;
[Display(Name = "PLZ")]
public string Zip;
[Display(Name = "Stadt")]
public string City;
}
それが私が今日やっている方法です。