DataConnector
In This Topic
    Scaffolding
    In This Topic

    At times, without the controls and designers that make configuration easy, designing applications in DataConnectors requires some extra effort. With the scaffolding feature for DataConnectors, you'll find that creating applications with DataConnector is much easier.

    For data connectors, scaffolding generates relevant model classes based on the source entities and also creates the DbContext class. Let's walk through how to get started with the scaffolders.

    Step 1: Create a new Console App

    1. Open Visual Studio
    2. Select File -> New -> Project.
    3. In the center pane, select Console App (.Net Core).
    4. Add a name for your app and select a location to save it.
    5. Click OK.

      Save app

    Step 2: Add the NuGet packages

    1. From the Project menu, select Manage NuGet Packages. The NuGet Package Manager appears.
    2. Select nuget.org from the Package source drop down.
    3. Click Browse tab and select C1.EntityFrameworkCore.Salesforce & Microsoft.EntityFrameworkCore.Tools (version 2.1.0) from the left pane.
    4. In the right pane, click Install. This adds the references for the above packages.

    Step 3: Initialize the Scaffolder

    Follow the steps provided below to learn and implement Scaffolding using ADO.NET provider for Salesforce. Similar steps can be used to implement scaffolding in other DataConnectors as well.

    1. Go to View -> Other Windows -> Package Manager Console from Visual Studio
    2. Run scaffolding command line with the following syntax to generate single table from the datasource.
      C#
      Copy Code
      Scaffold-DbContext "Username=****;Password=****;Security Token=****;OAuth Client Id=****; OAuth Client Secret=*****; OAuth Token Endpoint=https://ap17.salesforce.com/services/oauth2/token; Url=https://ap17.salesforce.com/services/data/v42.0" C1.EntityFrameworkCore.Salesforce -OutputDir "GeneratedCode" -Tables Account
      

      The above command line generates .cs files to represent the entity framework model for the "Account" table in the Salesforce datasource.

    3. Run scaffolding command line with the following syntax to generate two tables from the datasource.
      C#
      Copy Code
      Scaffold-DbContext "Username=****;Password=*****;Security Token=****;OAuth Client Id=******; OAuth Client Secret=******; OAuth Token Endpoint=https://ap17.salesforce.com/services/oauth2/token; Url=https://ap17.salesforce.com/services/data/v42.0" C1.EntityFrameworkCore.Salesforce -OutputDir "GeneratedCode" -Tables Account, Order
      

      The above command line generates .cs files to represent the entity framework model for the "Account and Order" table in the Salesforce datasource.

    4. Run scaffolding command line with the following syntax to generate all tables in the datasource.
      C#
      Copy Code
      Scaffold-DbContext "Username=****;Password=****;Security Token=****;OAuth Client Id=****; OAuth Client Secret=*****; OAuth Token Endpoint=https://ap17.salesforce.com/services/oauth2/token; Url=https://ap17.salesforce.com/services/data/v42.0" C1.EntityFrameworkCore.Salesforce
      

      The above command line generates .cs files to represent the entity framework model for the all tables in the Salesforce datasource.