This guide walks you through using Entity Framework Core to manage data operations in .NET applications. With the help of dotConnect for Zoho CRM, you'll learn how to generate EF Core models using the visual ORM tool, Entity Developer. We'll also build a console application and demonstrate how to implement CRUD operations efficiently using a well-structured connection class.
Why dotConnect for Zoho CRM?
Quick and easy integration
dotConnect enables straightforward connectivity between .NET applications and Zoho CRM, allowing developers to access CRM modules and records without working directly with Zoho's REST APIs.
User-friendly classes
Using familiar ADO.NET components, dotConnect for Zoho CRM allows developers to work with data through standard .NET data access patterns such as connections, commands, and data readers.
Advanced ORM support
dotConnect works with EF Core, Dapper, NHibernate, and LinqConnect, enabling flexible object-relational mapping and efficient interaction with Zoho CRM data in .NET applications.
Interactive OAuth token generation
Access to Zoho CRM is authorized through a browser-based login flow. After successful authentication, dotConnect automatically retrieves and manages access and refresh tokens for secure connections.
Full compliance with ADO.NET
Devart implements the standard ADO.NET provider model in dotConnect solutions, ensuring consistent behavior and compatibility with existing .NET frameworks and development tools.
Priority support & frequent updates
Devart provides professional technical assistance, comprehensive documentation, and ongoing product enhancements, helping developers maintain stable and reliable integrations with Zoho CRM.
Download and activate dotConnect for Zoho CRM
You can start using dotConnect for Zoho CRM immediately with a 30-day free trial. Choose one of the following installation options:
To connect to Zoho CRM using the built-in Data Explorer, click Tools and select Connect to Database.
Then, select the Zoho CRM data source, enter your Zoho domain, and click Web Login.
Log in to your Zoho account and grant access to the Zoho CRM company.
After that, select the tables and fields you want to work with and retrieve the data.
Build a Zoho CRM EF Core model
The Professional and Developer editions of dotConnect for Zoho CRM come equipped with Entity Developer, a robust ORM model designer and code generator that supports both Entity Framework and EF Core. This tool simplifies the process of generating a model from a data source or creating a data source from an existing model.
Follow the detailed illustrated guide to create your database model using Entity Developer. When this process is complete, it opens the model you created, ready for use.
Entity Developer generates classes for the selected tables, representing data entities. It also creates a ZohoModel class descendant to manage the connection to Zoho CRM and handle the data flow. This class contains properties and methods corresponding to your Zoho CRM objects, allowing you to retrieve and modify data easily.
DataModel1.ZohoModel.cs – You can extend functionality by writing custom partial classes and methods here
With the model set up, you are now ready to interact with Zoho CRM data using Entity Framework Core in your .NET application.
Note
If you're using a purchased license for dotConnect for Zoho CRM, include the License Key in the connection string. In our case, we will keep it in the DbContext class:
The authentication method: Refresh Token or OAuthInteractive
API Version
The version of the Zoho CRM API; note that API v1 has already reached the end-of-life phase
Domain
The Zoho CRM domain to connect to: crm.zoho.com or crm.zoho.eu or crm.zoho.com.cn or crm.zoho.in or crm.zoho.com.au
Client Id
The string that uniquely identifies a Zoho CRM company
Client Secret
A secret code mapped to a Zoho CRM client application; this parameter is used for connecting via API v2, and is filled automatically when you perform a web login
Refresh Token
The Zoho CRM OAuth refresh token used for connecting via API v2
License Key
The license key for dotConnect for Zoho CRM
Read data from Zoho CRM
In the Program.cs file, write the code to retrieve and display information from the Account table.
staticvoidDisplayAccounts()
{
using (var context = new ZohoModel())
{
var accounts = context.Accounts
.Select(a => new { a.AccountName, a.Phone, a.Website, a.AccountType })
.ToList();
foreach (var account in accounts)
{
Console.WriteLine($"Account Name: {account.AccountName}");
Console.WriteLine($"Phone: {account.Phone}");
Console.WriteLine($"Website: {account.Website}");
Console.WriteLine($"Account Type: {account.AccountType}");
Console.WriteLine(newstring('-', 20));
}
}
}
The console should display the AccountName, Phone, Website, and AccountType fields from the Account table in Zoho CRM.
Insert new data into Zoho CRM
This example demonstrates how to insert a new account into the Zoho CRM database using Entity Framework Core.
First, ensure that your Account class includes an Id field. To do this, right-click your model in Model Explorer and select Update Model from Database.
Next, select the newly added Id column and update the data model.
After updating, verify the properties of the Id field. Ensure that:
Primary Key is checked
Value Generated is set to OnAdd
Once these settings are configured, the model is ready for inserting new records into Zoho CRM.
Create a method in your Program class to add a new account to the Account table.
staticvoidAddNewAccount()
{
using (var context = new ZohoModel())
{
var newAccount = new Account
{
AccountName = "New Company Inc.",
Phone = "123-456-7890",
Website = "http://www.newcompany.com",
AccountType = "Customer"
};
context.Accounts.Add(newAccount);
context.SaveChanges();
Console.WriteLine("New account added successfully.");
}
}
Build and run your application.
Update Zoho CRM data
Now, let's update the phone number for an account with the name "Tom Ford" in Zoho CRM. This example assumes that the AccountName is unique or that you have a way to uniquely identify the account you want to update.
We retrieve the account named "Tom Ford" from the database and update the Phone property with a new phone number.
Here's how you can implement this in your Program class:
staticvoidMain(string[] args)
{
UpdateAccountPhoneNumber("Tom Ford", "222-333-4444");
DisplayAccounts();
}
staticvoidUpdateAccountPhoneNumber(string accountName, string newPhoneNumber)
{
using (var context = new ZohoModel())
{
// Fetch the account with the specified namevar account = context.Accounts
.FirstOrDefault(a => a.AccountName == accountName);
if (account != null)
{
// Update the phone number
account.Phone = newPhoneNumber;
// Save changes to the database
context.SaveChanges();
Console.WriteLine($"Phone number for {accountName} updated successfully.");
}
else
{
Console.WriteLine($"Account with name {accountName} not found.");
}
}
}
Here is the result.
Delete data from Zoho CRM
This example demonstrates how to fetch the account by name and then delete it from the database.
First, retrieve the account with the name "New Company Inc." from the database. Once you have the account, remove it from DbContext and save the changes.
This is how you can implement this in your Program class:
staticvoidMain(string[] args)
{
RemoveAccountByName("New Company Inc.");
DisplayAccounts();
}
staticvoidRemoveAccountByName(string accountName)
{
using (var context = new ZohoModel())
{
// Fetch the account with the specified namevar account = context.Accounts
.FirstOrDefault(a => a.AccountName == accountName);
if (account != null)
{
// Remove the account from the context
context.Accounts.Remove(account);
// Save changes to the database
context.SaveChanges();
Console.WriteLine($"Account with name {accountName} removed successfully.");
}
else
{
Console.WriteLine($"Account with name {accountName} not found.");
}
}
}
Here is what we get.
Conclusion
In this tutorial, we explored how the integration of Entity Framework Core with Zoho CRM using dotConnect for Zoho CRM simplifies data management in .NET applications. By combining the advanced capabilities of dotConnect with the power of Entity Framework Core, you can efficiently handle database operations in Zoho-powered applications. With these tools, you can develop scalable, maintainable, and robust .NET solutions that seamlessly interact with Zoho CRM data.
FAQ
How do I install and activate dotConnect for Zoho CRM in a .NET project?
Install dotConnect for Zoho CRM using the EXE installer or by adding the Devart.Data.Zoho NuGet package to your project. Then, obtain your Activation Key from your Devart Customer Portal and include it in the connection string via the License Key parameter.
How do I authenticate to Zoho CRM using Interactive OAuth in dotConnect?
To authenticate with Zoho CRM, use the connection string parameter Authentication Type=OAuthInteractive. When ZohoConnection opens, a browser window appears for you to sign in to your Zoho account and grant access. After authorization, dotConnect automatically retrieves and manages the access and refresh tokens.
How do I create a connection to Zoho CRM using dotConnect in C#?
Define a connection string that includes the URL of your Zoho CRM account, the authentication parameters, and the License Key. Then, create a ZohoConnection instance and call Open() inside a try-catch block to establish the connection and handle potential errors.
Can I query Zoho CRM data using SQL with dotConnect?
Yes, dotConnect allows you to retrieve and manage Zoho CRM modules using SQL queries. Developers can work with entities such as Leads, Contacts, Accounts, and Deals using familiar SQL syntax.
Can I connect to Zoho CRM using Entity Framework Core and dotConnect?
Yes, you can use Entity Developer to visually generate an EF Core model from Zoho CRM modules, or run Scaffold-DbContext with the Devart.Data.Zoho.EFCore package and a dotConnect connection string (including License Key) to create DbContext and entity classes.
Is it possible to explore Zoho CRM data using the Visual Studio Server Explorer with dotConnect?
Yes. Open Server Explorer in Visual Studio, add a new Data Connection, select dotConnect for Zoho CRM as the provider, configure OAuth authentication, test the connection, and browse Zoho CRM modules directly from the IDE.
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.