Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 在VB.NET MVC应用程序中创建实体框架Buddy类以扩展验证_Asp.net Mvc_Vb.net_Entity Framework 4_Buddy Class - Fatal编程技术网

Asp.net mvc 在VB.NET MVC应用程序中创建实体框架Buddy类以扩展验证

Asp.net mvc 在VB.NET MVC应用程序中创建实体框架Buddy类以扩展验证,asp.net-mvc,vb.net,entity-framework-4,buddy-class,Asp.net Mvc,Vb.net,Entity Framework 4,Buddy Class,在实体数据模型中,我有以下复杂类型 <EdmComplexTypeAttribute(NamespaceName:="MEMORABLEModel", Name:="EDMspGetContact_Result")> <DataContractAttribute(IsReference:=True)> <Serializable()> Partial Public Class EDMspGetContact_Result Inherits Comple

在实体数据模型中,我有以下复杂类型

<EdmComplexTypeAttribute(NamespaceName:="MEMORABLEModel", Name:="EDMspGetContact_Result")>
<DataContractAttribute(IsReference:=True)>
<Serializable()>
Partial Public Class EDMspGetContact_Result
    Inherits ComplexObject
#Region "Factory Method"
.... etc

部分公共类EDMspGetContact\u结果
继承ComplexObject
#区域“工厂法”
.... 等
我正在用VB.Net编写一个MVC4.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
_
_
部分公共类EDMspGetContact\u结果
请注意,该类中没有任何内容。这里只是添加class-level属性。
末级
公共类EDMspGetContact\u ResultMD
“”将字段命名为与EF命名的属性相同的名称,例如“FirstName”。
“”此外,类型需要匹配。基本上只是重新申报。
“”请注意,这是一个字段。我认为它也可以是一种财产,但田地肯定应该有用。
_
_
公共LastName作为字符串
末级

以上哪些类定义是EF生成的模型类?如果它是最后一个,则也需要将其标记为Partial,以便在分部类中定义的扩展成员成为同一个类的一部分。这可能意味着修改EF用于生成模型类的T4模板


这是假设您首先使用数据库或模型。如果您首先使用代码,我想您只需要将主模型类部分化。

类EDMspGetContact_的结果是EF生成的类。我使用数据库生成的存储过程来获取复杂类型。它们都声明为partial,但是MVC应用程序没有接收EDM类?