Work with data using code in Microsoft Dataverse
There are several different ways to access Dataverse data using code.
- Use the Dataverse SDK for .NET or Web API to retrieve, add, and modify data.
- Use Dataverse search search Dataverse data.
- Use the Dataverse Tabular Data Stream (TDS) endpoint to query data with SQL.
This article introduces the options you have to work with Dataverse data using code.
Retrieve, add, and modify data
Dataverse provides two ways to retrieve, add, and modify data: SDK for .NET & Web API. Choose the one that best matches the requirements, your skills, and preferences.
SDK for .NET
If you are working with .NET, we recommend using our SDK for .NET.
- Use the ServiceClient class in the DataverseServiceClient NuGet package if you have a client application.
- Use the Microsoft.CrmSdk.CoreAssemblies NuGet package when you're writing a plug-in or custom workflow activity.
The Dataverse SDK for .NET supports build targets for both .NET Framework and .NET 6+. However, plug-in and custom workflow activities must use .NET Framework.
If you're using our PowerShell module or using our custom log-in control with a Windows client application, use the the Xrm.Tooling
Web API
The Dataverse Web API is an OData v4 RESTful endpoint. Use the Web API for any programming language that supports HTTP requests and authentication using OAuth 2.0, including .NET.
- Learn to use the Dataverse Web API
- Quick Start: Web API with PowerShell and Visual Studio Code
- Quick Start: Web API sample (C#)
Search Dataverse data
Dataverse search delivers fast and comprehensive search results across multiple tables, in a single list, sorted by relevance. It also provides capabilities to support suggestions and autocompletion experiences in apps.
Search has a native endpoint and there are Dataverse messages that you can use from the Web API or SDK for .NET.
Learn to search for Dataverse records
Query data with SQL
The Power Query Dataverse connector uses the Dataverse Tabular Data Stream (TDS) endpoint to retrieve data using Dataverse SQL, a subset of Transact-SQL.
Retrieving data using SQL Management Studio (SSMS) is a preview feature.
Learn to use SQL to query data
Request and Response payload size limitations
The maximum payload size for any request sent to Dataverse is 128 MB. Requests with payloads over this limit receive a 413 Payload Too Large HTTP status code in the response.
There's a 1-GB size limitation on the size of a response that Dataverse returns. Few APIs or queries are capable of returning this much data. If you encounter this limit, you should consider what other options are available to get the data in multiple, smaller requests.
The deprecated SOAP endpoint payloads use serialized XML data that is much more verbose than the serialized JSON data payloads the Web API uses. You're less likely to encounter errors where the request or response payload is too large when you use the Web API. Learn about the legacy SOAP endpoint