Hi all,
We have set up Distributed SQL Server Cache by following this article
https://learn.microsoft.com/en-us/aspnet/core/performance/caching/distributed?view=aspnetcore-7.0. Currently we are running the following create table script manually on the database:
CREATE TABLE [dbo].DistCache
(
[Id] NVARCHAR(900) NOT NULL PRIMARY KEY,
[Value] VARBINARY(MAX) NOT NULL,
[ExpiresAtTime] DATETIMEOFFSET NOT NULL,
[SlidingExpirationInSeconds] BIGINT NULL,
[AbsoluteExpiration] DATETIMEOFFSET NULL
)
I wanted to do this programmatically on application start. I tried to follow this article here
https://docs.umbraco.com/umbraco-cms/v/10.latest-lts/extending/database. Here is my Disc Cache Schema
[TableName("dbo.DistCache")]
[PrimaryKey("Id")]
[ExplicitColumns]
public class DistCacheSchema
{
[PrimaryKeyColumn()]
[Column("Id")]
public String Id { get; set; }
[Column("Value")]
public Byte[] Value { get; set; }
[Column("ExpiresAtTime")]
public DateTimeOffset ExpiresAtTime { get; set; }
[Column("SlidingExpirationInSeconds")]
public Nullable<Int64> SlidingExpirationInSeconds { get; set; }
[Column("AbsoluteExpiration")]
public Nullable<DateTimeOffset> AbsoluteExpiration { get; set; }
}
This fails with the following error message
Microsoft.Data.SqlClient.SqlException: 'Identity column 'Id' must be of data type int, bigint, smallint, tinyint, or decimal or numeric with a scale of 0, unencrypted, and constrained to be nonnullable.'
Any ideas how to get this work?