Proposal: Generate strongly-typed Dataverse entity models compatible with Xrm.WebApi #314
Re-David-1992
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi 👋
First of all, thank you for building and maintaining DataverseDevTools;
it’s been extremely useful for improving developer productivity when working with Model Driven App web resources and TypeScript.
While using the extension I noticed that it already provides strong typing for form context, attributes, controls, and option sets, which is fantastic. However, when interacting with Xrm.WebApi, developers still have to rely heavily on:
Example today:
Although the form side is strongly typed, the moment we cross into WebApi operations, we lose most compile time safety.
Proposal
Introduce an optional code generator for strongly typed Dataverse entity models that work directly with Xrm.WebApi.
The goal is not to replace the native Xrm APIs, but to provide a typed model layer that reduces string literals and improves maintainability.
Example generated entity model:
Usage with native APIs:
Retrieve example:
Design approach
The idea is to introduce a base Entity class that provides shared mapping logic.
Example responsibilities of the base class:
Each generated entity class would provide metadata such as:
This keeps the entity model:
Benefits
Important notes
The intent would not be to build a full ORM or abstraction over Xrm.WebApi.
The entity models would simply provide:
All WebApi calls would still use the native Xrm APIs.
Potential scope for a first implementation
Future improvements could include things like typed request builders for Xrm.WebApi.online.execute, but that would be outside the initial scope.
Question for maintainers
Before investing time into a PR, I wanted to ask:
Happy to share a prototype or discuss alternative approaches if this direction seems useful.
Thanks again for the great tool!
Beta Was this translation helpful? Give feedback.
All reactions