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. To download and install the latest version of EF Core automatically, first run the following command:
Additionally, you'll need to install EF Core's Relational assembly, as shown in the following example::
You will need to specify an older version of EF Core if you are using the EF Core 2.1 version of our assemblies. To install EF Core 2.1, append the version tag at the end of each command:
Install-Package Microsoft.EntityFrameworkCore -Version 2.1.14 Install-Package Microsoft.EntityFrameworkCore.Relational -Version 2.1.14
The same information is applicable to our EF Core 2.0 assemblies.
Register the Entity Framework Core Provider
Complete the following steps to register the Entity Framework Core provider:
Note: EF Core 3.0 shares some files with EF Core 2.1.
- Add a reference to System.Data.CData.Asana.dll, located in the lib -> netstandard2.0 subfolder in the installation directory.
- Add a reference to CData.EntityFrameworkCore.Asana.dll For EF Core 3.0, this is located in the lib -> netstandard2.1 -> EFCORE30 subfolder in the installation directory. For EF Core 2.1, this is located in the lib -> netstandard2.0 -> EFCORE21 subfolder.
- 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.Asana.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.
- 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 Asana 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.
AsanaContext ents = new AsanaContext(); var projectsQuery = from projects in ents.projects orderby projects.WorkspaceId select projects;