Breeze / breeze.server.net

Breeze support for .NET servers
MIT License
76 stars 62 forks source link

.net Core entity framework + .expand #84

Closed ganySA closed 5 years ago

ganySA commented 5 years ago

Hi

I have successfully gotten most of the breeze working with .net core entity framework + .net core 3.0.

I experienced a few issues with naming conventions on the server and client side but those seem to have resolved.

One issue i am experiencing is with .expand("relatedEntityName"). I can see the data flowing back correctly from the .net core server but it causes an error.

This does not seem to work at all and causes the ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'entityState' of undefined

When i debug it - it looks like the related entity - entity aspect is empty...

ganySA commented 5 years ago

The actual error that is thrown is: TypeError: newValue.getProperty is not a function

Can you confirm that expand is working?

ganySA commented 5 years ago

The challenge was due to naming conventions in use when using dotnet-ef dbcontext Scaffold and Pluralizer.

The issue is with Bricelam.EntityFrameworkCore.Pluralizer. This library pluralizes the entities and this causes an issue with breeze - as breeze is not expecting the class to return a pluralized form for a navigation property.

Lets assume the object Clients which has a related property booking

Firstname Lastname Booking ----> Booking

When you call expand('Bookings') the server finds the right value and returns a list but when this arrives on the client there is no property Bookings and this causes it to fail.

When you remove the pluralizer you will call expand('Booking') when the server returns Booking this value maps correctly to the breeze local entity Booking.

This also happens in .net 3.0 however you cannot remove the pluralizer as at this point in time so you cannot use .net 3.0.

I am leaving this open for comment.

steveschmitt commented 5 years ago

We are using .expand successfully in .NET Core 2.2 using the Bricelam.EntityFrameworkCore.Pluralizer.

Are you expanding 1-to-many relationships, or 1-to-1?

ganySA commented 5 years ago

This was an issue with .net core 3.