在BreezeJS客户端中解析元数据时出现异常

时间:2015-01-22 09:45:30

标签: entity-framework enums metadata breeze

前传和版本信息:

BreezeJS客户端版本:1.5.2

通过设计时EntityFramework模型(6.1.2)在自定义服务器上生成的元数据

BreezeLabs EdmBuilder(1.0.5)

还有生成元数据的问题,可以在这里阅读: How to generate valid metadata from EF DBContext via EdmBuilder for OData v3/BreezeJS


问题/问题:

现在,breeze客户端在解释元数据时抛出错误。

Unable to process returned metadata: A nonnullable DataProperty cannot have a null defaultValue. Name: MySuperDuperEnum

例外情况发生在breeze.debug.js at line 7110 - function parseCsdlSimpleProperty(parentType, csdlProperty, keyNamesOnServer)

这里出了什么问题?我有错误的元数据吗?

以下是元数据:

<edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx">
    <edmx:DataServices m:DataServiceVersion="3.0" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
        <Schema Namespace="ODataMetaDataGenerator" xmlns="http://schemas.microsoft.com/ado/2009/11/edm">

            <EntityType Name="MyObject" p5:ClrType="GreatPersistencyNamespace.Model.GreatStuff.MyObject, BreezeEval, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" xmlns:p5="http://schemas.microsoft.com/ado/2013/11/edm/customannotation">
                <Key>
                    <PropertyRef Name="ID"/>
                </Key>
                <Property Name="ID" Nullable="false" Type="Edm.Int32" p7:StoreGeneratedPattern="Identity" xmlns:p7="http://schemas.microsoft.com/ado/2009/02/edm/annotation"/>
                <Property FixedLength="false" MaxLength="Max" Name="Name" Type="Edm.String" Unicode="true"/>
                <Property Name="IsActive" Nullable="false" Type="Edm.Boolean"/>
                <Property Name="IsGreat" Nullable="false" Type="Edm.Boolean"/>
                <Property FixedLength="false" MaxLength="Max" Name="Description" Type="Edm.String" Unicode="true"/>
                <Property Name="Address" Nullable="false" Type="ODataMetaDataGenerator.Address"/>
                <Property Name="BehaviourType" Nullable="false" Type="ODataMetaDataGenerator.BehaviourType"/>
            </EntityType>

            <EnumType Name="BehaviourType" UnderlyingType="Edm.Byte" p5:ClrType="GreatPersistencyNamespace.Model.GreatStuff.BehaviourType, BreezeEval, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" xmlns:p5="http://schemas.microsoft.com/ado/2013/11/edm/customannotation">
                    <Member Name="RUDE" Value="1"/>
                    <Member Name="KIND" Value="2"/>
                    <Member Name="UNKNOWN" Value="3"/>
            </EnumType>

            <EntityContainer Name="TheGreatModelContainer" p5:UseClrTypes="true" xmlns:p5="http://schemas.microsoft.com/ado/2013/11/edm/customannotation"   >
                    <EntitySet EntityType="ODataMetaDataGenerator.MyObject" Name="MyObjects"/>
            </EntityContainer>

        </Schema>
    </edmx:DataServices>
</edmx:Edmx>

错误的确切来源位于breeze.debug.js at line 8597 - constructor of DataProperty

必须设置defaultValue,在我的情况下,它尝试从属性dataType中获取默认值。 此时的dataType如下所示:

{
    name: "Undefined",
    defaultValue: undefined
}

由于line 7091 - var dataType = DataType.fromEdmDataType(csdlProperty.type);

失败,会发生这种情况

因为csdlProperty看起来像:

{
    name: "BehaviourType",
    nullable: undefined
    type: "ODataMetaDataGenerator.BehaviourType"
}

当然,这不是一个Edm-Type,因此失败了..这里应该使用枚举的基础类型吗?

0 个答案:

没有答案