I've read a lot about OData with EF Core / ASP.NET Core. It seems to me that everybody has an opinion on this and It's gotten a bit confusing, so at the risk of sounding dumb, I have a few questions:
Please note:
! I'm NOT talking about the classic ASP.NET 4.6 or 4.7 with EF6 !
! I'm talking about ASP.NET Core with EF Core !
Considering building API - Is there stuff that EF Core alone couldn't handle as well as EF Core with OData?
Considering building API - Is it not better to build clean RESTful APIs instead of OData style APIs?
Isn't implementing OData stuff sacrificing best practices for convenience?
What about long term? Aren't ASP.NET Core + EF Core being built with speed and efficiency in mind and thus won't they be faster and more efficient on their own?
Keep using EF6 if the data access code is stable and not likely to evolve or need new features. Port to EF Core if the data access code is evolving or if the app needs new features only available in EF Core. Porting to EF Core is also often done for performance.
OData uses the Entity Data Model (EDM) to describe the structure of data. In ASP.NET Core OData, it's easy to build the EDM based on the above CLR types (Entity, Complex, Enum). With that in mind, let's add the following private static method at the end of Startup.
Dapper is literally much faster than Entity Framework Core considering the fact that there are no bells and whistles in Dapper. It is a straight forward Micro ORM that has minimal features as well. It is always up to the developer to choose between these 2 Awesome Data Access Technologies.
There's currently no support for using the EF designer directly on . NET Core or . NET Standard projects.
I will go with Shawn Wildermuth's advice that I found on Pluralsight:
OData means that queries are on the client so that versioning OData services becomes risky and it feels like MS is moving away from it so I don't have confidence in the long-term viability of it either.
OData on ASP.NET Core/EF Core works very well. Versioning can be accomplished with microsofts versioning api. I don't necessarily see MS abandoning this technology. There main api (ms graph) is odata 4 compatible.
Using Odata on top of EF Core is really enjoyable for many use cases. Especially the querying part I like a lot. For implementing writes/commands I usually fall back to webapi/Mediatr.
Here https://www.jannikbuschke.de/blog/cqrs-with-mediatr-and-odata/ and here https://www.jannikbuschke.de/blog/odata-getting-started/ I wrote some thoughts/guides on this topic.
One downside is tooling and community. There is not a whole lot out there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With