Question

I have an OData service that exposes an EF data model that was created using a database first approach. Everything is working, however now I want to add additional properties to the entities that will not be part of the database. It are readonly properties.

However when I add additional properties (with partial classes), the properties are not added to the automatically created entities when updating the service reference to my OData service.

Since these additional properties cannot be mapped to database queries I wonder if such a thing is even possible? And if not, I wonder what the best approach would be to add readonly properties, say through extra methods?

Does anybody know how to do so? I have searched high and low but cannot find anything about this subject.

Thanks in advance

Was it helpful?

Solution

You can try open type, which allows to have additional undefined properties of a complex type property or an entity. You can reference this blog How to Use Open Type in OData to implement your open type.

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