Question

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,

Cannot insert NULL in RowID column

even though I've written insert trigger for specifying the value of RowID column.

mapping.Id(x => x.Id, "RowID").GeneratedBy.TriggerIdentity();
Était-ce utile?

La solution

You are using a FOR trigger; this is a different way of specifying an AFTER trigger. And you need to switch this to an "INSTEAD OF" trigger.Please refer to this webpage.

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top