Airtable.EFCore 1.1.0

dotnet add package Airtable.EFCore --version 1.1.0                
NuGet\Install-Package Airtable.EFCore -Version 1.1.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Airtable.EFCore" Version="1.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Airtable.EFCore --version 1.1.0                
#r "nuget: Airtable.EFCore, 1.1.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Airtable.EFCore as a Cake Addin
#addin nuget:?package=Airtable.EFCore&version=1.1.0

// Install Airtable.EFCore as a Cake Tool
#tool nuget:?package=Airtable.EFCore&version=1.1.0                

Airtable.EFCore

Entity Framework Core provider for Airtable.

Uses Airtable.Net library by ngocnicholas.

Based and inspired mostly by Cosmos DB provider by Microsoft.

State of the project and motivation

This project was created to support charity operations of UA Responders charity that runs it's internal operations on Airtable and Azure Functions.

Because Airtable is a good simple UI and database, but lacks good automation facilities, we run some of our automations on Azure Functions in C#.

Currently all operations on Azure Functions are ported to work on top of this provider, and features added are based on needs to support those operations.

Only small subset of LINQ is translated, but there is a foundation to add features as needed.

Changetracking and SaveChangesAsync() works, so you can do full CRUD cycle.

Usage

Create Airtable base

Get Airtable base ID and API key

Install Airtable.EFCore package.

//Register airtable as EF provider
services.AddDbContext<TestDbContext>(o => o.UseAirtable(config.GetValue<string>("BaseId"), config.GetValue<string>("ApiKey")));

Example model:

Create your model. Example uses Inventory Tracking template.


public class TestDbContext : DbContext
{
    public TestDbContext(DbContextOptions options) : base(options)
    {
    }

    public DbSet<DbProductInventory> ProductInventory { get; set; }
    public DbSet<DbManufacturer> Manufacturers { get; set; }

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder.Entity<DbProductInventory>().ToTable("Product Inventory");
        base.OnModelCreating(modelBuilder);
    }
}

public class DbManufacturer
{
    public string Id { get; set; }
    public string Name { get; set; }
    [Column("Contact Name")]
    public string ContactName { get; set; }

    public AirtableAttachment Image { get; set; }
}

public class DbProductInventory
{
    public string Id { get; set; }

    [Column("Units Ordered")]
    public int Ordered { get; set; }

    [Column("Product Name")]
    public string ProductName { get; set; }
}

And you can work with it as with regular EF model!

Translated features

Airtable Views

FromView extension limit querying to specific view.

await db.Manufacturers.FromView("San").FirstOrDefaultAsync(i=>i.Name == "Something");

Airtable formulas translated

C# Airtable Comment
= = Simple equality operator
Regex.IsMatch REGEX_MATCH() No options additional supported by airtable
String.Equals Equality operator = Case insensitivity achieved via UPPER function
String.Contains FIND() Case insensitivity achieved via UPPER function
&& AND
\|\| OR
DateTimeOffset comparison operators Combination of NOT and IS_AFTER and IS_BEFORE
Entity property reference Record property reference encoded in {}
Entity primary key reference RECORD_ID() With special optimization for query by primary key only

Attachment support

Use property of type AirtableAttachment or ICollection<AirtableAttachment> to work with attachments.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.0 206 2/18/2024
1.0.0 144 2/11/2024
0.2.7 297 10/29/2023
0.2.6.4 140 5/19/2023
0.2.6.1 217 3/12/2023
0.2.6 213 3/12/2023
0.2.5.4 239 1/8/2023
0.2.5.2 254 1/8/2023