【发布时间】:2013-08-07 08:18:03
【问题描述】:
我需要为实体框架自动生成的属性添加一些属性,并且不想在重新生成对象时丢失它们。我也不想碰T4。
查看interenet我发现部分类可以添加MetaDataType,如:
<MetadataType(GetType(Employee_Metadata))> _
Partial Public Class employee
...
然后创建另一个类,我们将实际的元数据添加到属性中:
Public Class Employee_Metadata
<Category("General"), DisplayName("Name"), Description("Employee name.")> _
Public Property employee_name() As String
Get
Return _employee_name
End Get
Set(value As String)
_employee_name = value
End Set
End Property
Private _employee_name As String
End Class
现在,我还需要做什么才能访问这些属性? 我目前正在将 UI 组件绑定到类员工自动生成的属性“employee_name”(使用 MVVM)。我是否需要在部分类中进一步更改某些内容,还是应该更改数据绑定本身(在本例中为 WPF)?
【问题讨论】:
标签: entity-framework properties attributes metadata