ID 存储在哪里?
我使用 Elmah 和 Log4Net(带有 ADONetAppender),它们都很棒。但是,我注意到两者都有一个表 ID 键(递增数字),当我清除它们的日志时,它不会重置为零。他们从哪里获得这个 ID 值?另外,log4net 列是否有任何理由不使用主键作为 ID 值,或者如果我添加一个主键,我会遇到麻烦?
I use both Elmah and Log4Net (with ADONetAppender), and they are great. However, I notice that both have a table ID key (incrementing number), which doesn't reset back to zero when I clear their logs. Where are they getting this ID value from? Also, is there any reason for log4net columns not to use a Primary Key for the ID value, or rather will I have trouble if I add one?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我怀疑这是数据库中
ID
字段上的自动增量
指令,因为当您删除条目时,该值不会重置为零,仅在截断时(请更正)我,我不确定)。尝试直接重置数据库中的表,而不是使用记录器基础设施。I suspect it is an
auto increment
directive on theID
field in the database, as this value doesn't reset to zero when you delete entries, only when truncanted (please correct me, I'm not sure about it). Try reseting the table in the database directly instead of using the logger infrastructure.如果您使用的是 Microsoft SQL Server,则可以使用
DBCC CHECKIDENT
语句如下:例如,要将
ELMAH_Error
表的 IDENTITY 列重置为值 1,您可以使用:快乐编程!
If you are using Microsoft SQL Server then you can reset an IDENTITY column seed using the
DBCC CHECKIDENT
statement like so:For example, to reset the
ELMAH_Error
table's IDENTITY column to a value of 1 you would use:Happy Programming!