Save Big on Cyber Monday! Up to 40% Off
ends in   {{days}}
Days
{{timeFormat.hours}}
:
{{timeFormat.minutes}}
:
{{timeFormat.seconds}}

Getting Started With dotConnect for Salesforce

Below are some resources to help you maximize your experience with dotConnect for Salesforce.

dotConnect for Salesforce is a high-performance ADO.NET data provider with ORM support, offering fast and encrypted access to Salesforce data for application development.

  • EF Core, Dapper, NHibernate ORM support
  • Local SQL engine with support for SQL-92
  • Broad compatibility with various .NET platforms and versions
  • Full compliance with ADO.NET
  • Integration with Visual Studio

Code examples

using Devart.Data.Salesforce;

namespace SalesforceConsoleApp {
  class Program {
    static void Main(string[] args) {
      string connectionString =
        "Authentication Type=UserNamePassword;" +
        "Host=salesforce.com;" +
        "User [email protected];" +
        "Password=;" +
        "Security Token=;" +
        "License Key=**********;";

      using (var connection = new SalesforceConnection(connectionString))
      {
        connection.Open();
        Console.WriteLine(connection.State); // Prints: Open
      }
    }
  }
}
PM> Install-Package Devart.Data.Salesforce
using System;
using Devart.Data.Salesforce;

namespace SalesforceConsoleApp
{
  class Program
  {
    static void Main(string[] args)
    {
      string connectionString =
        "Authentication Type=UserNamePassword;" +
        "Host=salesforce.com;" +
        "User [email protected];" +
        "Password=;" +
        "Security Token=;" +
        "License Key=**********;";

      using (var connection = new SalesforceConnection(connectionString))
      {
        connection.Open();
        Console.WriteLine(connection.State); // Open

        string soql = "SELECT Id, Name, Industry, BillingCity FROM Account LIMIT 15";
        using (var cmd = new SalesforceCommand(soql, connection))
        using (var reader = cmd.ExecuteReader())
        {
          Console.WriteLine("Id\t\t\t\tName\t\t\tIndustry\tBillingCity");
          Console.WriteLine("----------------------------------------");

          while (reader.Read())
          {
            Console.WriteLine(
              $"{reader["Id"]}\t{reader["Name"],-24}\t{reader["Industry"],-12}\t{reader["BillingCity"]}");
          }
        }
      }

      Console.WriteLine("\nPress any key to exit...");
      Console.ReadKey();
    }
  }
}
PM> Install-Package Devart.Data.Salesforce
using Microsoft.EntityFrameworkCore;
using Devart.Data.Salesforce.EFCore;

namespace EfCoreSalesforceDemo
{
  // Map to Salesforce Account object
  public class Account
  {
      public string Id { get; set; } = "";
      public string Name { get; set; } = "";
      public string? Industry { get; set; }
      public string? BillingCity { get; set; }
  }

  public class SalesforceContext : DbContext
  {
    private readonly string _connectionString;
    public SalesforceContext(string connectionString) => _connectionString = connectionString;
    public DbSet<Account> Accounts => Set<Account>();

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        => optionsBuilder.UseSalesforce(_connectionString);

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        var e = modelBuilder.Entity<Account>();
        e.ToTable("Account"); // Salesforce object
        e.HasKey(a => a.Id);  // Primary key
        e.Property(a => a.Id).HasColumnName("Id");
        e.Property(a => a.Name).HasColumnName("Name");
        e.Property(a => a.Industry).HasColumnName("Industry");
        e.Property(a => a.BillingCity).HasColumnName("BillingCity");
    }
  }

  class Program
  {
    static void Main(string[] args)
    {
      // Fill in Password, Security Token, License Key
      var connectionString =
        "Authentication Type=UserNamePassword;" +
        "Host=salesforce.com;" +
        "User [email protected];" +
        "Password=YOUR_PASSWORD;" +
        "Security Token=YOUR_TOKEN;" +
        "License Key=**********;";

      using var db = new SalesforceContext(connectionString);

      Console.WriteLine("Fetching first 15 accounts...\n");

      var accounts = db.Accounts
                        .OrderBy(a => a.Name)
                        .Select(a => new { a.Id, a.Name, a.Industry, a.BillingCity })
                        .Take(15)
                        .ToList();

      Console.WriteLine("Id\t\t\t\tName\t\t\tIndustry\tBillingCity");
      Console.WriteLine("------------------------------------------");

      foreach (var a in accounts)
        Console.WriteLine($"{a.Id}\t{a.Name,-24}\t{a.Industry,-12}\t{a.BillingCity}");

      Console.WriteLine("\nDone. Press any key to exit...");
      Console.ReadKey();
    }
  }
}
PM> Install-Package Devart.Data.Salesforce.EFCore
using System;
using System.Data;
using Devart.Data.Salesforce;

namespace SalesforceConsoleApp
{
  class Program
  {
    static void Main(string[] args)
    {
      string connectionString =
        "Authentication Type=UserNamePassword;" +
        "Host=salesforce.com;" +
        "User [email protected];" +
        "Password=;" +
        "Security Token=;" +
        "License Key=**********;";

      using (var connection = new SalesforceConnection(connectionString))
      {
        connection.Open();
        Console.WriteLine(connection.State); // Open

        string soql = "SELECT Id, Name, Industry, BillingCity FROM Account LIMIT 15";

        using (var adapter = new SalesforceDataAdapter(soql, connection))
        {
          var table = new DataTable("Account");
          adapter.Fill(table);

          Console.WriteLine("Id\t\t\t\tName\t\t\tIndustry\tBillingCity");
          Console.WriteLine("---------------------------------");

          foreach (DataRow row in table.Rows)
          {
            string id = row["Id"].ToString();
            string name = row["Name"]?.ToString() ?? "";
            string industry = row.IsNull("Industry") ? "" : row["Industry"].ToString();
            string city = row.IsNull("BillingCity") ? "" : row["BillingCity"].ToString();

            Console.WriteLine($"{id}\t{name,-24}\t{industry,-12}\t{city}");
          }
        }
      }

      Console.WriteLine("\nPress any key to exit...");
      Console.ReadKey();
    }
  }
}
PM> Install-Package Devart.Data.Salesforce
using System;
using Devart.Data.Salesforce;

namespace SalesforceConsoleApp
{
  class Program
  {
    static void Main(string[] args)
    {
      string connectionString =
        "Authentication Type=UserNamePassword;" +
        "Host=salesforce.com;" +
        "User [email protected];" +
        "Password=;" +
        "Security Token=;" +
        "License Key=**********;";

      using (var connection = new SalesforceConnection(connectionString))
      {
        connection.Open();
        Console.WriteLine(connection.State); // Open

        // Begin a transaction
        var tx = connection.BeginTransaction();

        try
        {
          // 1) Insert Account
          string insertAccountSql =
            "INSERT INTO Account (Name, Industry, BillingCity) " +
            "VALUES (@Name, @Industry, @BillingCity)";

          using (var insertAccount = new SalesforceCommand(insertAccountSql, connection))
          {
            insertAccount.Transaction = tx;
            insertAccount.Parameters.AddWithValue("@Name", "Contoso (TX Demo)");
            insertAccount.Parameters.AddWithValue("@Industry", "Technology");
            insertAccount.Parameters.AddWithValue("@BillingCity", "Warsaw");
            insertAccount.ExecuteNonQuery();
          }

          // 2) Get the new Account Id
          string getAccountId =
            "SELECT Id FROM Account WHERE Name = @Name ORDER BY CreatedDate DESC LIMIT 1";

          string accountId;
          using (var getIdCmd = new SalesforceCommand(getAccountId, connection))
          {
            getIdCmd.Transaction = tx;
            getIdCmd.Parameters.AddWithValue("@Name", "Contoso (TX Demo)");
            accountId = Convert.ToString(getIdCmd.ExecuteScalar());
          }

          // 3) Insert a related Contact
          string insertContactSql =
            "INSERT INTO Contact (FirstName, LastName, Email, AccountId) " +
            "VALUES (@FirstName, @LastName, @Email, @AccountId)";

          using (var insertContact = new SalesforceCommand(insertContactSql, connection))
          {
            insertContact.Transaction = tx;
            insertContact.Parameters.AddWithValue("@FirstName", "Jane");
            insertContact.Parameters.AddWithValue("@LastName", "Doe");
            insertContact.Parameters.AddWithValue("@Email", "[email protected]");
            insertContact.Parameters.AddWithValue("@AccountId", accountId);
            insertContact.ExecuteNonQuery();
          }

          // Commit all operations atomically
          tx.Commit();
          Console.WriteLine("Transaction committed.");
        }
        catch
        {
          // Roll back all changes on any failure
          tx.Rollback();
          Console.WriteLine("Transaction rolled back.");
        }
      }

      Console.WriteLine("\nPress any key to exit...");
      Console.ReadKey();
    }
  }
}
PM> Install-Package Devart.Data.Salesforce
using System;
using Devart.Data.Salesforce;

namespace SalesforceConsoleApp
{
  class Program
  {
    static void Main(string[] args)
    {
      string connectionString =
        "Authentication Type=UserNamePassword;" +
        "Host=salesforce.com;" +
        "User [email protected];" +
        "Password=;" +
        "Security Token=;" +
        "License Key=**********;";

      using (var connection = new SalesforceConnection(connectionString))
      {
        try
        {
          connection.Open();
          Console.WriteLine($"Connection: {connection.State}"); // Open

          // Intentionally trigger an error: omit required field Name
          string sql = "INSERT INTO Account (Industry) VALUES (@Industry)";
          using (var cmd = new SalesforceCommand(sql, connection))
          {
            cmd.Parameters.AddWithValue("@Industry", "Technology");
            cmd.ExecuteNonQuery(); // Should throw
          }
        }
        catch (SalesforceException ex)
        {
          Console.WriteLine("SalesforceException caught");
          Console.WriteLine($"ErrorCode: {ex.ErrorCode}");
          Console.WriteLine($"Message  : {ex.Message}");
          if (ex.InnerException != null)
            Console.WriteLine($"Inner    : {ex.InnerException.Message}");
        }
        catch (Exception ex)
        {
          Console.WriteLine("General exception caught");
          Console.WriteLine(ex.Message);
        }
      }

      Console.WriteLine("\nPress any key to exit...");
      Console.ReadKey();
    }
  }
}
PM> Install-Package Devart.Data.Salesforce

How-to articles

.NET Connection Strings for Salesforce
Learn how to set up connection strings properly when working with dotConnect for Salesforce in .NET applications.
Connect to Salesforce in .NET
Explore how to establish a connection between .NET applications and Salesforce using ADO.NET.
Connect to Salesforce with EF Core
Find out how to connect Salesforce to your application using EF Core and ADO.NET.
Connect to Salesforce With Dapper
Learn how to integrate Salesforce with .NET Blazor applications using EF Core and ADO.NET.
Connect to Salesforce in Blazor
Learn how to connect C# to Salesforce using Dapper for fast and efficient data access.
Connect to Salesforce in MAUI
See how to build .NET MAUI applications and perform CRUD operations with Salesforce using ADO.NET.

Documentation

Licensing
Licensing
A detailed technical reference on embedding license information - a required resource for applications built with dotConnect for Salesforce.
DataAdapter features
DataAdapter features
A guide to using the SalesforceDataAdapter class for interacting with Salesforce data in a disconnected architecture.
Parameters
Parameters
An overview of SQL query parameters and their synchronization, along with practical insights into working with stored procedures.
SQL translation
SQL translation
Since remote execution is significantly faster than client-side processing, using translatable SQL ensures optimal query performance.

dotConnect Universal

Get universal access to data from a variety of sources, including SQL Server, Oracle, PostgreSQL, MySQL, SQLite, DB2, InterBase, Microsoft Access, and Firebird. Other servers can be accessed through their ADO.NET, OLE DB and ODBC providers.

FAQ

What is the trial period for dotConnect for Salesforce?
dotConnect for Salesforce offers a fully functional 30-day trial. During this period, you can use and evaluate all features without limitations. After the trial ends, you can purchase a license to keep using the product.
Why do I need to install the product if NuGet is available?

dotConnect for Salesforce provides two sets of assemblies, and the choice depends on your project type:

  • For .NET Framework projects: Use the Devart assemblies included with the product installer.
  • For .NET (.NET Core/.NET 5+) projects: Use the assemblies available via NuGet packages.
Where should I apply my License Key?

The method for applying your license depends on your project type:

  • For .NET (.NET Core/.NET 5+) projects, apply the License Key at runtime using the License Key connection string parameter.
  • For .NET Framework projects, no license key is needed. Simply download and install the licensed version of dotConnect from your Devart Customer Portal.
What editions of dotConnect for Salesforce are available, and what's the difference?

There are five editions:

  • Standard - Full ADO.NET provider with design-time support.
  • Professional - Adds ORM tools like Entity Framework and LinqConnect.
Do end users of my application need a Devart license, or do I have to pay additional fees for deploying my software?

No, end users do not need a Devart license, and there are no additional deployment fees, as long as you hold a valid Devart license.

According to the EULA, you're allowed to redistribute the following runtime assemblies with your application:

  • Devart.Data.Salesforce.dll
  • Devart.Data.dll

You can include them in your app's folder (such as Bin for web apps) or register them in the GAC. Just make sure they are only used by your solution.

There's no need for a full installation on the target machine, you can also use the "Minimal installation" option provided by the setup.

No other components of dotConnect may be distributed.

How can I update dotConnect to a new version?

To update dotConnect to a new version, you need to reinstall it:

  • 1. Open Settings > Apps > Installed apps in Windows.
  • 2. Uninstall the current and any older versions of dotConnect, including Entity Developer and LinqConnect, if installed.
  • 3. Visit the Customer Portal and download the latest licensed version.
  • 4. Install the downloaded version and receive the latest features and improvements.
How can I completely remove all previous versions of a product?

1. Go to Settings > Apps > Installed apps and uninstall:

  • All dotConnect providers
  • Entity Developer
  • LinqConnect

2. Manually delete any leftover files from the following locations (if they exist):

GAC folders:

  • C:\Windows\assembly\GAC_MSIL
  • C:\Windows\Microsoft.NET\assembly\GAC_MSIL

Program files and extensions:

  • C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\Extensions\Devart
  • C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\Extensions\Devart
  • C:\Program Files (x86)\Devart
  • C:\Program Files\Devart
  • C:\Program Files (x86)\Common Files\Devart
  • C:\Program Files\Common Files\Devart

Program data folders:

  • C:\ProgramData\Devart\dotConnect
  • C:\ProgramData\Devart\Entity Developer
  • C:\ProgramData\Devart\EntityDeveloper

Removing these ensures a clean system and prevents conflicts during future installations.

Wield the full firepower of dotConnect for Salesforce
Go with the advanced edition of dotConnect for Salesforce and stay at the top of your game from day one!