views:

285

answers:

0

I am using entity framework, using (almost) hand-crafted csdl, ssdl, and msl files. I've noticed that object construction seems to fail if the name of the EntityContainer consists of a single word.

For example, for the following two csdl files :

<Schema Namespace="BestProduct"
    Alias="Self"
    xmlns="http://schemas.microsoft.com/ado/2006/04/edm"&gt;

<EntityContainer Name="BestProduct">
    <EntitySet Name="Customer" EntityType="BestProduct.Customer" />
</EntityContainer>

    <EntityType Name="Customer">
        <Key>
            <PropertyRef Name="Name" />
        </Key>
        <Property Name="Name" Type="String" Nullable="false" />
        <Property Name="Age" Type="Int32" Nullable="false" />
        <Property Name="Address" Type="String" Nullable="false" />
    </EntityType>

</Schema>

and

<Schema Namespace="Product"
    Alias="Self"
    xmlns="http://schemas.microsoft.com/ado/2006/04/edm"&gt;

<EntityContainer Name="Product">
    <EntitySet Name="Customer" EntityType="Product.Customer" />
</EntityContainer>

    <EntityType Name="Customer">
        <Key>
            <PropertyRef Name="Name" />
        </Key>
        <Property Name="Name" Type="String" Nullable="false" />
        <Property Name="Age" Type="Int32" Nullable="false" />
        <Property Name="Address" Type="String" Nullable="false" />
    </EntityType>

</Schema>

the following happens :

        var bp = new BestProduct.BestProduct();
        foreach (var c in bp.Customer) 
            Console.WriteLine(c.Name);

        var p = new Product.Product();
        foreach (var c in p.Customer)
            Console.WriteLine(c.Name); // <-- Null refrence right here

The object returned by the ObjectQuery in the second case is null, the only difference in the two cases being the single-worded EntityContainer name.

The entity classes were generated from the csdl files using the `edmgen' tool.

You can download the sample project from here.