简体   繁体   English

在SQL Server中流畅使用nhibernate TriggerIdentity是否存在问题?

[英]Issue with fluent nhibernate TriggerIdentity in SQL Server?

When I tried to insert data into a table in SQL Server, which has an ID column specification as following, I'm getting the error, 当我尝试将数据插入SQL Server的表中时,该表具有如下的ID列规范,但出现错误,

Cannot insert NULL in RowID column 无法在RowID列中插入NULL

even though I've written insert trigger for specifying the value of RowID column. 即使我已经编写了用于指定RowID列值的插入触发器。

mapping.Id(x => x.Id, "RowID").GeneratedBy.TriggerIdentity();

You are using a FOR trigger; 您正在使用FOR触发器; this is a different way of specifying an AFTER trigger. 这是指定AFTER触发器的另一种方式。 And you need to switch this to an "INSTEAD OF" trigger.Please refer to this webpage . 并且您需要将其切换为“ INSTEAD OF”触发器。请参阅此网页

The reason it is failing now is because SQL Server validation is occurring prior to your trigger executing and performing it's primary key creation. 现在失败的原因是因为SQL Server验证是在触发器执行并执行主键创建之前进行的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM