ADO.NET Provider for GraphQL

Build 21.0.7940

EFCore Console Application

Install Entity Framework Core

From a .NET core console app, install and configure the Entity Framework Core environment. Use the Package Manager Console in Visual Studio to install the appropriate version of EF Core.

The following versions are supported through bundled assemblies.

  • 3.0
  • 3.1
  • 5.0

To download and install EF Core automatically, first run one of the following commands:

Install-Package Microsoft.EntityFrameworkCore -Version 3.0 //Run this command if using EF Core 3.0
Install-Package Microsoft.EntityFrameworkCore -Version 3.1 //Run this command if using EF Core 3.1
Install-Package Microsoft.EntityFrameworkCore -Version 5.0 //Run this command if using EF Core 5.0

Additionally, you'll need to install EF Core's Relational assembly, as shown in the following example::

Install-Package Microsoft.EntityFrameworkCore.Relational -Version 3.0  //Run this command if using EF Core 3.0
Install-Package Microsoft.EntityFrameworkCore.Relational -Version 3.1  //Run this command if using EF Core 3.1
Install-Package Microsoft.EntityFrameworkCore.Relational -Version 5.0  //Run this command if using EF Core 5.0

Register the Entity Framework Core Provider

Complete the following steps to register the Entity Framework Core provider:

  1. Add a reference to System.Data.CData.GraphQL.dll, located in the lib -> netstandard2.0 subfolder in the installation directory.
  2. Add a reference to CData.EntityFrameworkCore.GraphQL.dll. For EF Core 3.1, this is located in lib -> netstandard2.1 -> EFCORE30 For EF Core 3.0 and 5.0, this is located in the lib -> netstandard2.0 -> EFCORE31 subfolder and lib -> netstandard2.0 -> EFCORE50 subfolder in the installation directory, respectively.
  3. Add the included licensing file (.lic) to your project. You can accomplish this by right-clicking the project in the Solution Explorer, then navigating to Add -> Existing Item -> System.Data.CData.GraphQL.lic (located in the lib -> netstandard2.0 subfolder in your installation directory). Finally, right-click the licensing file, and set Copy to Output Directory to Copy if newer.
  4. Build the project to complete the setup for using EF Core.

Creating the Data Model

There are two approaches that can be taken in creating the context and entity classes for your application. With the Code-First Approach approach, you can fine-tune your model by writing the classes manually. Alternatively, you can make use of Reverse Engineering (Scaffolding) to generate these classes automatically from your GraphQL schema.

Perform LINQ Commands in Your Code

You are now ready to start using LINQ in your code. Be sure to declare "using System.Linq" in your file.

GraphQLContext ents = new GraphQLContext();
var UsersQuery = from Users in ents.Users
                   orderby Users.Email
                   select Users;

Copyright (c) 2021 CData Software, Inc. - All rights reserved.
Build 21.0.7940