Using Entity Framework Core with Cloud Spanner

The Cloud Spanner Entity Framework Core provider allows you to create a Cloud Spanner database, run queries, and update data through an application using Entity Framework Core. The provider is compatible with Microsoft.EntityFrameworkCore 3.1.

Setting up the Cloud Spanner Entity Framework Core provider

To setup the Cloud Spanner Entity Framework Core provider in your application, add the following dependency.

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp3.1</TargetFramework>
  </PropertyGroup>

  ...

  <ItemGroup>
    <PackageReference Include="Docker.DotNet" Version="3.125.5" />
    <PackageReference Include="Google.Cloud.EntityFrameworkCore.Spanner" Version="1.0.0" />
  </ItemGroup>

  ...

</Project>

As authentication for the Cloud Spanner Entity Framework Core provider, the service account JSON credentials file location should be provided in the GOOGLE_APPLICATION_CREDENTIALS environment variable. Otherwise, the provider can also use the default credentials set in the Google Cloud CLI gcloud application.

Using the Cloud Spanner Entity Framework Core provider

For more information about the available features, limitations of the provider, recommendations on how to use the provider, and for code samples, please consult the reference documentation on GitHub.

What's next