0
votes

Using breeze.js (master branch) and angular on client with odata4j on the server-side, I'm receiving the following error if i want to query for countries:

var query = breeze.EntityQuery.from('Country');
entityManager.executeQuery(query).then(...).fail(...);

-> Unable to locate a 'Type' by the name: Country:#odataContainer 

I've configured breeze as follows:

  breeze.config.initializeAdapterInstances({dataService: "OData"});
  breeze.NamingConvention.none.setAsDefault();

.../$metadata OData response:

<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx">
 <edmx:DataServices m:DataServiceVersion="2.0" xmlns:m="...">
   <Schema Namespace="odataContainer" xmlns="...">
     <EntityContainer Name="odataEntities" m:IsDefaultEntityContainer="true">
       <EntitySet Name="Country" EntityType="odataModel.Country">
       </EntitySet>
     </EntityContainer>
   </Schema>
   <Schema Namespace="odataModel" xmlns="...">
     <EntityType Name="Country">
       <Key>
         <PropertyRef Name="countryCode"></PropertyRef>
       </Key>
       <Property Name="region" Type="Edm.String" Nullable="true"></Property>
       <Property Name="population" Type="Edm.Int32" Nullable="false"></Property>
       <Property Name="countryCode" Type="Edm.String" Nullable="false"></Property>
       <Property Name="name" Type="Edm.String" Nullable="true"></Property>
     </EntityType>
   </Schema>
 </edmx:DataServices>
</edmx:Edmx>
1

1 Answers

0
votes

You need to include namespace for you models in your project. In case your Country class is in odataModel.Country you need to add the third line to configure oData service:

ODataModelBuilder builder = new ODataConventionModelBuilder();
builder.EntitySet<Department>("Countries");
builder.Namespace = "odataModel.Country";