Exception while parsing metadata in BreezeJS client

依然范特西╮ 提交于 2019-12-11 03:12:33

问题


Prequel and version info:

BreezeJS client version: 1.5.2

Metadata generated on custom server via design-time EntityFramework model (6.1.2)

BreezeLabs EdmBuilder (1.0.5)

Had problems generating metadata also which can be read here: How to generate valid metadata from EF DBContext via EdmBuilder for OData v3/BreezeJS


Question/Problem:

Now the breeze client is throwing an error while interpreting the metadata.

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

The exception occurs in breeze.debug.js at line 7110 - function parseCsdlSimpleProperty(parentType, csdlProperty, keyNamesOnServer).

Whats going wrong here? Do I have wrong metadata?

Here is the metadata:

<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>

The exact source of the error is in breeze.debug.js at line 8597 - constructor of DataProperty.

There the defaultValue has to be set and in my case it tries to get the default value from the property dataType. The dataType at this point looks the following:

{
    name: "Undefined",
    defaultValue: undefined
}

This happens due to a failure in line 7091 - var dataType = DataType.fromEdmDataType(csdlProperty.type);

because csdlProperty looks like:

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

Which of course is not an Edm-Type and thus fails.. Should the underlying type of the enum be used here?

来源:https://stackoverflow.com/questions/28085482/exception-while-parsing-metadata-in-breezejs-client

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!