ADO.NET Provider for MYOB

Build 24.0.9060

Reverse Engineering (Scaffolding)

Reverse engineering (via scaffolding) is a process which streamlines OR/M by automatically constructing classes for all of the tables and views available via the MYOB schema. This process also creates a CDataContext class, which extends DbContext and exposes the DbSet properties that represent the tables in the data source.

Install Entity Framework Core Tools

If you're making use of scaffolding in a console app, you'll first need to install the EF Tools via the Package Manager Console (PMC).

Install-Package Microsoft.EntityFrameworkCore.Tools -Version 6.0 //Run this command if using EF Core 6.0

Scaffolding

Scaffolding is performed using the PMC in Visual Studio. You can use following commands to scaffold.

Scaffold All Tables

Use the following command to scaffold all tables and views from the schema into your Models folder:

Scaffold-DbContext " If using an online instance: InitiateOAuth=GETANDREFRESH;OAuthClientId=YourClientId;OAuthClientSecret=YourClientSecret;CompanyFileId=yourCompanyFileId;CallbackURL=http://localhost:33333;User=companyFileUser;Password=companyFilePassword; If using an on premise instance: InitiateOAuth=OFF;URL=http://localhost:8080/accountright;CompanyFileId=327eed10-9615-4e5e-bd9e-ae2cc00e2c70;User=companyFileUser;Password=companyFilePassword;" CData.EntityFrameworkCore.MYOB -OutputDir Models -Context MYOBContext

Scaffold A Subset of Tables

You can also refine the scaffolding process to only create classes for a limited selection of tables. This is especially useful when a large schema is taking a long time to scaffold due to the large number of classes it has to generate. This is accomplished by specifying the tables/views that you want to scaffold at the end of your Scaffold-DbContext command in the PMC.

Scaffold-DbContext " If using an online instance: InitiateOAuth=GETANDREFRESH;OAuthClientId=YourClientId;OAuthClientSecret=YourClientSecret;CompanyFileId=yourCompanyFileId;CallbackURL=http://localhost:33333;User=companyFileUser;Password=companyFilePassword; If using an on premise instance: InitiateOAuth=OFF;URL=http://localhost:8080/accountright;CompanyFileId=327eed10-9615-4e5e-bd9e-ae2cc00e2c70;User=companyFileUser;Password=companyFilePassword;" CData.EntityFrameworkCore.MYOB -OutputDir Models -Context MYOBContext  -Tables Accounts 

Updating your Data Model

If you would like to re-scaffold to update the model with additional table classes after the initial generation, simply add a '-Force' argument to any Scaffold-DbContext command. The existing model will then be overwritten with your changes.

Copyright (c) 2024 CData Software, Inc. - All rights reserved.
Build 24.0.9060