Question

I have a Web App built using breeze js to communicate with a breeze api controller on top of entity framework.

I want to have the properties names and nav properties by in camelCase. on the server they are PascalCase.

Following the instructions here I added this to my code:

 breeze.NamingConvention.camelCase.setAsDefault();

As a result I am now getting an error when breeze is trying to get the metadata

 Error: Metadata import failed for Breeze/ZenAPI/Metadata; Unable to process
 returned metadata:NamingConvention for this server property name does not roundtrip properly:houseId-->HouseId

Things I know:

  1. All the properties are PascalCased on the server.
  2. There is no non default formatter set on the server.
  3. When I look at the server response it is in Pascal.
  4. If I take out this setting, everything works fine and the naming is Pascal.
  5. The setting is set, meaning that when I check

    breeze.NamingConvention.defaultInstance.name;

I get "camelCase";

What might be the reason for the problem?

Was it helpful?

Solution

NamingConvention.camelCase is intended for use in converting server property names that are PascalCased into CamelCased names on the client. According to the error message, you are trying to do the reverse, i.e. in your case 'houseId' is a server property name.

When metadata is being processed breeze attempts to verify that every property name can be roundtripped by passing it thru the NamingConvention.clientPropertyNameToServer method and then thru the NamingConvention.serverPropertyNameToClient method or the reverse depending on whether a client or a server name is provided within the metadata. The message you got indicates that

ServerName   ClientName   ServerName   
----------   ----------   ---------  
'houseId' -> 'houseId' -> 'HouseId'   ( 'houseId' != 'HouseId');

Note that if 'HouseId' was the server name then this works just fine.

ServerName   ClientName   ServerName   
----------   ----------   ---------  
'HouseId' -> 'houseId' -> 'HouseId'   ( 'HouseId' == 'HouseId');

If it turns out that you really do want 'houseId' as both the server name and the client name, then you will need to write your own NamingConvention ( which is actually pretty easy). See http://www.breezejs.com/sites/all/apidocs/classes/NamingConvention.html

OTHER TIPS

I found that with Code First generation of the model with Entity Framework Powertools on EF6+ did not allow for the selection of database objects, consequently the table "sysdiagrams" came across all in lowercase instead of the Pascal Case notation I normally use for db objects. Once I removed this table from the model and context classes, then this error with breeze went away. All good. I also tested with breeze.NamingConvention.none.setAsDefault() and used Pascal case in my javascript and that worked OK too, but not preferred.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top