Without the controls and designers that make configuration easy, designing applications in DataConnectors may at times require some extra effort. With the scaffolding feature for DataConnectors, creating applications with DataConnector becomes easier, as it generates relevant model classes based on the source entities, while also creating the DbContext class.
This is a walk-through for getting started with Scaffolding.
To implement Scaffolding using ADO.NET provider in Visual Studio, navigate to View -> Other Windows -> Package Manager Console.
To generate .cs files that represent the entity framework model for all the tables in the Salesforce datasource, run scaffolding command line with the following syntax (similar commands can be used to implement scaffolding in other DataConnectors as well):
PowerShell |
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 |
To generate a single table (here "Account"), add the -Tables modifier, followed by the name of the table, like in the code below:
PowerShell |
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 |
For multiple tables (here "Account" and "Order"), add their names separated by comma, like in the code below:
PowerShell |
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 |