有一个asp.net核心Web应用程序,并尝试将Serilog与SQL Sink一起使用,我只想使用下面的简单表结构进行记录。我不断收到一个错误,指示我的列映射与表不对齐。好吧,那很简单,只有我看不到我缺少任何列。
有没有办法获取诊断消息以告诉我看不到哪一列?
CREATE TABLE [dbo].[Logs](
[Id] [INT] IDENTITY(1,1) NOT NULL,
[Message] [NVARCHAR](MAX) NULL,
[Level] [VARCHAR](100) NULL,
[TimeStamp] [DATETIME] NULL,
CONSTRAINT [PK_Logs] 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]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
我正在使用已经具有现有连接字符串的appsettings.json文件,如何避免两次定义连接字符串?
"Serilog": {
"Using": [ "Serilog.Sinks.MSSqlServer" ],
"MinimumLevel": "Information",
"WriteTo": [
{
"Name": "MSSqlServer",
"Args": {
"connectionString": "Data Source=.;Initial Catalog=MyDb;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
"tableName": "Logs",
"columnOptionsSection": {
"removeStandardColumns": [ "MessageTemplate","Exception", "Properties","LogEvent" ]
}
}
}
]
}
[更新]
我在Github页面上创建了默认的表结构,然后开始删除那些我不需要的列。当我删除“属性”时,即使我将配置设置为删除该列,我也开始再次遇到映射错误。
Db中的“属性”是否为必填字段?