Getting Started With dotConnect for Salesforce Marketing Cloud

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

dotConnect for Salesforce Marketing Cloud is a high-performance ADO.NET data provider with ORM support. It offers fast and encrypted access to Salesforce Marketing Cloud data for application development.

  • Support for EF Core, Dapper, NHibernate, and other ORMs
  • 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.ExactTarget;

namespace SalesforceMCApp
{
    class Program
    {
        static void Main(string[] args)
        {
            string connectionString =
              "Authentication Type=UserNamePassword;" +
              "User=TestUser;" +
              "Password=TestPassword;" +
              "Url=https://your-exacttarget-url;" +
              "License Key=**********;";

            using (var connection = new ExactTargetConnection(connectionString))
            {
                connection.Open();
                Console.WriteLine(connection.State);
            }
        }
    }
}
PM> Install-Package Devart.Data.ExactTarget
using Devart.Data.ExactTarget;

namespace SalesforceMCApp
{
    class Program
    {
        static void Main(string[] args)
        {
            string connectionString =
              "Authentication Type=UserNamePassword;" +
              "User=TestUser;" +
              "Password=TestPassword;" +
              "Url=https://your-exacttarget-url;" +
              "License Key=**********;";

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

                string soql = "SELECT Id, Name, Industry, BillingCity FROM Account LIMIT 15";
                using (var cmd = new ExactTargetCommand(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"]}");
                    }
                }
            }
        }
    }
}
PM> Install-Package Devart.Data.ExactTarget
using Microsoft.EntityFrameworkCore;
using Devart.Data.ExactTarget.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.UseExactTarget(_connectionString);

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        var e = modelBuilder.Entity<Account>();
        e.ToTable("Account");
        e.HasKey(a => a.Id);
        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;" +
        "User=TestUser;" +
        "Password=TestPassword;" +
        "Url=https://your-exacttarget-url;" +
        "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.ExactTarget.EFCore
using System.Data;
using Devart.Data.ExactTarget;

namespace SalesforceMCApp
{
    class Program
    {
        static void Main(string[] args)
        {
            string connectionString =
              "Authentication Type=UserNamePassword;" +
              "User=TestUser;" +
              "Password=TestPassword;" +
              "Url=https://your-exacttarget-url;" +
              "License Key=**********;";

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

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

                using (var adapter = new ExactTargetDataAdapter(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.ExactTarget
using Devart.Data.ExactTarget;

namespace SalesforceMCApp
{
    class Program
    {
        static void Main(string[] args)
        {
            string connectionString =
                          "Authentication Type=UserNamePassword;" +
                          "User=TestUser;" +
                          "Password=TestPassword;" +
                          "Url=https://your-exacttarget-url;" +
                          "License Key=**********;";

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

                // 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 ExactTargetCommand(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 (simple lookup by name for demo purposes)
                    string getAccountId =
                        "SELECT Id FROM Account WHERE Name = @Name ORDER BY CreatedDate DESC LIMIT 1";

                    string accountId;
                    using (var getIdCmd = new ExactTargetCommand(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 ExactTargetCommand(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.ExactTarget
using Devart.Data.ExactTarget;

namespace SalesforceMCApp
{
    class Program
    {
        static void Main(string[] args)
        {
            string connectionString =
                                      "Authentication Type=UserNamePassword;" +
                                      "User=TestUser;" +
                                      "Password=TestPassword;" +
                                      "Url=https://your-exacttarget-url;" +
                                      "License Key=**********;";

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

                    string sql = "INSERT INTO Account (Industry) VALUES (@Industry)";
                    using (var cmd = new ExactTargetCommand(sql, connection))
                    {
                        cmd.Parameters.AddWithValue("@Industry", "Technology");
                        cmd.ExecuteNonQuery();
                    }
                }
                catch (ExactTargetException ex)
                {
                    Console.WriteLine("ExactTargetException 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.ExactTarget

Documentation

Licensing
Licensing
A detailed technical reference on embedding license information - a required resource for applications built with dotConnect for Salesforce MC.
DataAdapter features
DataAdapter features
A guide to enabling interactions with Salesforce Marketing Cloud in a disconnected architecture using the ExactTargetDataAdapter class.
Parameters
Parameters
An overview of SQL query parameters and their synchronization, along with practical insights into working with stored procedures.
SQL translation
SQL translation
An example of dotConnect translating a subset of SQL-92 SELECT statements into SOQL for remote execution, which is faster than client-side processing.

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 Marketing Cloud?
dotConnect for Salesforce Marketing Cloud 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 Marketing Cloud 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.
Do the end users of my application need a Devart license, or do I have to pay additional fees for deploying my software?

No, the 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.ExactTarget.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

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

Wield the full firepower of dotConnect for Salesforce Marketing Cloud
Go with the advanced edition of dotConnect and stay at the top of your game from day one!
Try the 30-day trial of the full product. No limits. No card required. Start free trial