.NET MAUI (Multi-platform App UI) is a framework developed by Microsoft for building native mobile and desktop applications using C# and .NET. It allows developers to create apps that run on Android, iOS, Windows, and macOS. One of its biggest advantages is the ability to use a single codebase letting the developers share code, tests, and program logic across multiple platforms.
A key aspect of app development is ensuring a reliable connection to data sources and direct data management within the application. Data connectivity solutions, such as Devart's dotConnect products, help us resolve these challenges efficiently.
In this article, we'll explore how to connect a .NET MAUI application to a Salesforce data source using ADO.NET and perform read, insert, and delete operations.
Why dotConnect for Salesforce?
Easy integration with Salesforce
Ensures effortless connection to Salesforce, enabling users to access data easily and intuitively.
No Salesforce API and SOQL learning
Supports familiar SQL statements, requiring no special knowledge of a complex API or SOQL.
User-friendly ADO.NET classes
Uses well-known ADO.NET classes, enabling an easy start and creating a convenient working environment.
Advanced ORM support
Fully supports EF Core, Dapper, NHibernate, LinqConnect, and other technologies for efficient data management.
Full ADO.NET compliance
Conforms to the latest ADO.NET standards and innovations for seamless integration with .NET applications.
Priority support & frequent updates
Includes priority support, detailed documentation, and regular updates for continuous improvement.
Download and activate dotConnect for Salesforce
You can start using dotConnect for Salesforce immediately with a 30-day free trial. Choose one of the following installation options:
To connect to Salesforce and access the data, you need the security token. Sign in to your Salesforce account, go to your profile > Settings. Navigate to Reset My Security Token and request it. A new token will be sent to your email. We'll use it for API access when we establish connection to Salesforce.
Create a connection
This article includes a sample of the code that you can use to connect to Salesforce using dotConnect within a .NET MAUI project.
Replace the placeholders with your valid Salesforce credentials: Host, UserID, Password, and Security Token.
Note
For a paid dotConnect for Salesforce license, include the license key in the code. For the trial version, remove the License Key line.
The authentication method for connecting to Salesforce, such as UserNamePassword, AccessRefreshToken, AccessRefreshTokenInteractive, SessionId, etc.
Host
The Salesforce.com or Database.com login URL, such as login.salesforce.com, login.database.com, test.salesforce.com, etc.
User ID -or- User
The Salesforce login account.
Password
The password for the account.
Refresh token
The Salesforce OAuth 2.0 refresh token used for the OAuth Refresh Token authentication.
Security token
User ID used to authenticate with MySQL.
License key
The license key.
We are going to use our demo SalesforceMaui project to illustrate the READ, INSERT, and DELETE operations.
Read Salesforce data
To read and display data from your Salesforce account in an MAUI app, use the code below in the SalesforceService.cs class. In this code, the following ADO.NET classes are used:
SalesforceConnection manages the connection lifecycle.
SalesforceCommand represents the SQL query.
SalesforceDataReader reads query results row by row.
<VerticalStackLayoutPadding="10"Spacing="10"><LabelText="Add New Lead"FontAttributes="Bold"FontSize="20"HorizontalOptions="Center" /><GridColumnDefinitions="*,3*"RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto,Auto"RowSpacing="15"Padding="0,10,0,10"><!-- First Name --><LabelText="First Name:"VerticalTextAlignment="Center" /><Entryx:Name="FirstNameEntry"Placeholder="First Name"Grid.Column="1" /><!-- Last Name --><LabelText="Last Name:"VerticalTextAlignment="Center"Grid.Row="1" /><Entryx:Name="LastNameEntry"Placeholder="Last Name"Grid.Row="1"Grid.Column="1" /><!-- Company --><LabelText="Company:"VerticalTextAlignment="Center"Grid.Row="2" /><Entryx:Name="CompanyEntry"Placeholder="Company"Grid.Row="2"Grid.Column="1" /><!-- Title --><LabelText="Title:"VerticalTextAlignment="Center"Grid.Row="3" /><Entryx:Name="TitleEntry"Placeholder="Title"Grid.Row="3"Grid.Column="1" /><!-- Phone --><LabelText="Phone:"VerticalTextAlignment="Center"Grid.Row="4" /><Entryx:Name="PhoneEntry"Placeholder="Phone"Grid.Row="4"Grid.Column="1" /><!-- Email --><LabelText="Email:"VerticalTextAlignment="Center"Grid.Row="5" /><Entryx:Name="EmailEntry"Placeholder="Email"Grid.Row="5"Grid.Column="1" /><!-- Status --><LabelText="Status:"VerticalTextAlignment="Center"Grid.Row="6" /><Entryx:Name="StatusEntry"Placeholder="Status"Grid.Row="6"Grid.Column="1" /></Grid></VerticalStackLayout><ButtonText="Add Lead"Clicked="OnAddLeadClicked" />
Delete Salesforce records
To delete records from the Salesforce tables, use the code below with the following ADO.NET classes:
SalesforceConnection manages the database connection lifecycle.
SalesforceCommand represents the SQL query and executes it.
SalesforceParameter binds parameters securely to the SQL query.
.NET MAUI is a popular framework for cross-platform application development. In this process it is crucial to ensure efficient connectivity to data sources. dotConnect products provide that required secure, direct connection and allow direct data manipulation from within the application.
If your MAUI app relies on Salesforce, dotConnect for Salesforce grants a stable connection and enables you to manage Salesforce tables without additional clients or learning new technologies.
You can test dotConnect for Salesforce under real workloads with a 30-day free trial. Download, install, and start building your applications!
FAQ
How do you install and activate dotConnect for Salesforce in a .NET project?
Install dotConnect for Salesforce via the EXE installer or by adding the Devart.Data.Salesforce NuGet package to your project, then obtain your personal activation key from your Devart Customer Portal and include it in the connection string via the License Key parameter for a working connection.
How do you create a connection to Salesforce using dotConnect in C#?
Define a connection string that includes host, user ID, password, database, and the License Key value, then create a SalesforceConnection instance with this string and call Open() for it inside a try-catch block to test and handle connection errors.
How do you enable encryption for secure Salesforce connections with dotConnect?
Use Salesforce Native Network Encryption by configuring encryption in the sqlnet.ora file on both client and server sides. No special parameters are required in the connection string.
Can you connect to Salesforce using Entity Framework Core and dotConnect?
Yes, you can either use Entity Developer to visually create an EF Core model from the database or run Scaffold-DbContext with a dotConnect connection string (including License Key) to generate the DbContext and entity classes.
Is it possible to connect to Salesforce using Visual Studio Server Explorer with dotConnect?
Yes, it is possible. All you need to do is navigate to Visual Studio Server Explorer, add a new Data Connection, choose dotConnect for Salesforce as the data provider, enter your credentials, test the connection, and then browse Salesforce data directly in Visual Studio.
I'm a technical content writer who loves turning complex topics — think SQL, connectors, and backend chaos–into content that actually makes sense (and maybe even makes you smile). I write for devs, data folks, and curious minds who want less fluff and more clarity. When I'm not wrangling words, you'll find me dancing salsa, or hopping between cities.