在实体数据模型中,我有以下复杂类型
<EdmComplexTypeAttribute(NamespaceName:="MEMORABLEModel", Name:="EDMspGetContact_Result")>
<DataContractAttribute(IsReference:=True)>
<Serializable()>
Partial Public Class EDMspGetContact_Result
Inherits ComplexObject
#Region "Factory Method"
.... etc
我正在 VB.Net 中编写一个 MVC 4.0 应用程序
我想在我的解决方案的另一个项目中为复杂类型定义添加验证
我试图在我的 MVC 项目中定义一个部分类,但即使它编译我也知道它是错误的,因为脚手架模板不会生成所有属性
在过去的 6 个月里,我已经从传统编码转向面向对象编码,我真的很难克服这样的问题。感谢指导我哪里出错了。我试过添加一个命名空间。
<MetadataType(GetType(EDMspGetContact_ResultMD))> _
<ScaffoldTable(True)> _
Partial Public Class EDMspGetContact_Result
' Note this class has nothing in it. It's just here to add the class-level attribute.
End Class
Public Class EDMspGetContact_ResultMD
' ' Name the field the same as EF named the property - "FirstName" for example.
' ' Also, the type needs to match. Basically just redeclare it.
' ' Note that this is a field. I think it can be a property too, but fields definitely should work.
<Required()> _
<Display(name:="Last Name")> _
Public LastName As String
End Class