I can define in my SQL Server a column with the following definition:
[Barcode] AS ([Prefix] + CONCAT(REPLICATE('0', (4)-LEN([ContainerId])), [ContainerId])) PERSISTED,
This basically allows me to store a value on the database row with a given prefix like this:
ContainerId Prefix Barcode
----------------------------------
23 TUB TUB0023
This works great but when I try to describe this for Entity Framework in the OnModelCreating
:
entity.Property(f => f.Barcode).HasComputedColumnSql("[Prefix]+CONCAT(REPLICATE('0',(4)-LEN([ContainerId])),[ContainerId])");
and use it in a unit test, I get the following error:
Microsoft.Data.Sqlite.SqliteException : SQLite Error 1: 'no such function: replicate'.
Is there a limitation on using in-memory Entity Framework computed columns such that we can't have this call to HasComputedColumnSql
in the OnModelBuilding
event?