dotnet-spanner-entity-framework icon indicating copy to clipboard operation
dotnet-spanner-entity-framework copied to clipboard

scaffolding: CHECK CONSTRAINT cannot be scaffolded

Open olavloite opened this issue 4 years ago • 0 comments

EF Core supports defining check constraints when working code-first, but there is nothing in the scaffolding metadata that allows us to define this when generating code from the database. This means that when a database with existing CHECK constraints is scaffolded and the output is used to generate a new database, the CHECK constraints will not be included in the new database.

Script: CONSTRAINT Chk_Languages_Lyrics_Length_Equal CHECK (ARRAY_LENGTH(LyricsLanguages) = ARRAY_LENGTH(Lyrics))

Actual:

entity.HasAnnotation("CONSTRAINT `Chk_Languages_Lyrics_Length_Equal`", "CHECK ARRAY_LENGTH(LyricsLanguages) = ARRAY_LENGTH(Lyrics)");

Expected:

entity.HasCheckConstraint("Chk_Languages_Lyrics_Length_Equal", "ARRAY_LENGTH(LyricsLanguages) = ARRAY_LENGTH(Lyrics)");

olavloite avatar Jan 29 '21 07:01 olavloite