googleapis / googleapis/dotnet-spanner-entity-framework

scaffolding: computed column does not include `HasComputedColumnSql`.

Open
#9 0 comments 0 reactions 0 assignees View on GitHub
known limitation type: feature request
Dominant language
C#
Stars
34
Forks
13
Avg merge
4h 39m
Merged PRs (30d)
10

Description

The current scaffolding generator ensures that a valid `DbContext` that can be used is generated. If we also include the computed SQL in the meta model, EF Core will not respect the `ValueGeneratedOnAddOrUpdate` part of the meta model, and will try to insert values into the computed column. Cloud Spanner does not allow that.

Query:
`FullName STRING(400) NOT NULL AS (COALESCE(FirstName || ' ', '') || LastName) STORED,`

Actual:
```cs
entity.Property(e => e.FullName)
.IsRequired()
.HasMaxLength(400)
.ValueGeneratedOnAddOrUpdate();
```

Excepted:
```cs
entity.Property(e => e.FullName)
.IsRequired()
.HasMaxLength(400)
.ValueGeneratedOnAddOrUpdate()
.HasComputedColumnSql("(COALESCE(FirstName || ' ', '') || LastName) STORED");
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.