Google Cloud Spanner

Requirements

Google Cloud Spanner support relies on the Google.Cloud.Spanner.Data ADO.NET provider that's included with the driver in the LLBLGen Pro installation. To be able to create a model from an existing Google Cloud Spanner database, you have to have access to a Google Cloud Spanner instance and you have to have setup Google Cloud tools on the system you're using the LLBLGen Pro designer on, using the Spanner getting started guide.

Supported features

Feature Supported
Database types All built-in types, except Array and Struct
User defined types No
Foreign key constraints No (Interleaved tables are seen as having a Foreign Key Constraint with the parent table)
Primary key constraints Yes
Unique constraints No
Check constraints No
Default values No (Allow_commit_timestamp is seen as a default value for Timestamp fields)
Unique indexes No
Tables Yes
Views No
Stored Procedures No
Table Valued Functions No
(System versioned) Temporal tables No
Synonyms No
Cascade delete rules Yes
Cascade update rules No
Identity fields No
System sequences No
Schema based sequences No
Multiple catalogs per project No
Multiple schemas per catalog No
Linked servers No
Important!

Google Cloud Spanner doesn't support the addition/removal of PK fields on an existing table. The LLBLGen Pro designer doesn't have validation for this and will generate DDL SQL scripts which make this happen. This is by design, to illustrate that the PK has changed. It's then up to you how to proceed: drop the existing table and re-create it, or alter the model.

Type mappings

Below you'll find the two type mapping tables used by the Google Cloud Spanner driver of LLBLGen Pro. One is used for Database First development, the other is used for Model First development. In case of Model First development, you can add your own type shortcuts to define a different target database type, in case the default mappings aren't what you need in a particular case.

Database first type mappings

You can control the .NET type during reverse engineering in database first development by defining Type Conversions in the Project Settings, which are based on Type Converters.

Database type .NET Type
Bool System.bool
Bytes System.Byte[]
Date System.DateTime
Float64 System.double
Int64 System.long
String System.string
Timestamp System.DateTime

Model first type mappings

If specified, the filter is combined with the .NET type to determine the database type. The elements length, precision and scale are the max. length, precision and scale of an entity field with the particular .NET Type.

.NET Type Database type
System.Bool Bool
System.Byte[] Bytes
System.DateTime Timestamp
System.Double Float64
System.Int64 Int64
System.String String

Recommendations

Google Cloud Spanner is a database with a specific set of characteristics and it's highly recommended you set the following settings to true, in Project Settings, before creating an entity model

  • Use custom field ordering on new elements, under Entity Model\General
  • Reset field order based on target order at relational model data sync, under Entity Model\Database first Development

Other recommendations

  • Google Cloud Spanner doesn't have the concept of Foreign Keys. The Designer will see an interleaved table as a table with a foreign key constraint with its parent table. To define additional relationships, all relationships have to be model only. This way the relationship isn't expected to have a backing foreign key constraint.

  • If you want to use Model First and model Timestamp columns as allow_commit_timestamp columns, please create a new type shortcut in the project, for the .NET Type 'DateTime' and the DB Type 'Timestamp' and set its default value to 'allow_commit_timestamp' (lowercase). Using that typeshortcut as an entity field will then cause the default to be added to the field and will make it become an allow_commit_timestamp field.

  • If you want to create an interleaved table using Model first development, create an entity which has a PK-PK relationship with another entity. The PK-PK relationship shouldn't be model-only so the designer will create a foreign key constraint for it in the relational model data when you sync the model.

Supported target frameworks

The following target frameworks are supported with Google Cloud Spanner:

  • LLBLGen Pro Runtime Framework