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 10.0 package:
Install-Package Microsoft.EntityFrameworkCore -Version 10.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 10.0
- To support command-line tools like Scaffold-DbContext, install the tools package:
Install-Package Microsoft.EntityFrameworkCore.Tools -Version 10.0
EF Core 10.0 requires .NET 10. Make sure your project targets .NET 10.
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.Exchange.dll, located in the lib -> netstandard2.0 subfolder in the installation directory.
- Add a reference to CData.EntityFrameworkCore.Exchange.dll:
- This is located in the lib -> net10.0 -> EFCORE100 subfolder.
- Add the included licensing file (System.Data.CData.Exchange.lic) to your project:
- Right-click the project in Solution Explorer and choose Add -> Existing Item.
- Browse to the file in lib -> netstandard2.0.
- Right-click the file and click Properties to open the Properties menu.
- In the Properties menu, set Copy to Output Directory to Copy if newer.
- Build the project (Build > Build Solution) 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 Microsoft Exchange schema using scaffolding tools.