且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

上的EntityFramework类AllowHtml属性

更新时间:2023-11-28 11:12:04

您可以使用 MetadataTypeAttribute 一>指定在相关(好友)类生成的code属性。所以,你放在一个单独的类属性的,不会与code再生成下列程序进行:

You can use the MetadataTypeAttribute to specify attributes for the generated code in an associated (buddy) class. So you put your attributes in a separate class which won't be effected with the code re-generation:

[MetadataType(typeof(YourEntityMetadata))]
public partial class YourEntityClass
{            
}   

public class YourEntityMetadata
{
    [AllowHtml]
    public string YourPropertyWithHtml { get; set; }
}

在元数据类中的属性名称应与实体属性的名称。

The property names in the Metadata class should match your entity property names.