我的 Saga 课程如下:
public class SagaData : IContainSagaData
{
[Unique]
public virtual string SagaKey { get; set; }
public virtual string Data { get; set; }
#region IContainSagaData
public virtual Guid Id { get; set; }
public virtual string Originator { get; set; }
public virtual string OriginalMessageId { get; set; }
#endregion IContainSagaData
}
我在 MSSQL 中坚持 Sagas。创建的表结构如下:
CREATE TABLE [dbo].[SagaData](
[Id] [uniqueidentifier] NOT NULL,
[SagaKey] [nvarchar](255) NULL,
[Data] [nvarchar](255) NULL,
[Originator] [nvarchar](255) NULL,
[OriginalMessageId] [nvarchar](255) NULL,
PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
UNIQUE NONCLUSTERED
(
[SagaKey] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
Data
属性(字符串类型)已映射到nvarchar(255)
. 显然,当我为该属性分配超过 255 个字符时,它会失败并显示 message: String or binary data would be truncated
。我怎么能强迫它nvarchar(max)
呢?
我正在使用 NServiceBus 4.4.2。