Getting Started with EF Core
Install Entity Framework Core
Entity Framework Core is distributed via NuGet. Run the following command in the Package Manager Console in Visual Studio to install the base EF Core 8.0 package:
Install-Package Microsoft.EntityFrameworkCore -Version 8.0
You may also need additional packages depending on your project:
- To enable design-time features such as scaffolding or migrations, install the design package:
Install-Package Microsoft.EntityFrameworkCore.Design -Version 8.0
- To support command-line tools like Scaffold-DbContext, install the tools package:
Install-Package Microsoft.EntityFrameworkCore.Tools -Version 8.0
EF Core 8.0 requires .NET 8. Make sure your project targets .NET 8.
Register the Entity Framework Core Provider
After installing the required NuGet packages, complete the following steps to register the CData EF Core provider in your project:
- Add a reference to System.Data.CData.QuickBooks.dll, located in the lib -> netstandard2.0 subfolder in the installation directory.
- Add a reference to CData.EntityFrameworkCore.QuickBooks.dll:
- This is located in the lib -> net8.0 -> EFCORE80 subfolder.
- Add the included licensing file (System.Data.CData.QuickBooks.lic) to your project:
- Right-click the project in Solution Explorer and choose Add -> Existing Item.
- Browse to the file in lib -> netstandard2.0.
- After adding, right-click the file and set Copy to Output Directory to Copy if newer.
- Build the project to complete EF Core registration and ensure all dependencies are linked.
Creating the Data Model
You can create EF Core models using one of two approaches:
- Code-First Approach manually define entity and context classes in code for full control over the model.
- Reverse Engineering (Scaffolding) automatically generate models from your live QuickBooks schema using scaffolding tools.