You can add the check constraint by adding CheckConstraint("configurationId = 1")
to your ClassMap
:
class ConfigurationMap : ClassMap<Configuration>
{
public ConfigurationMap()
{
Id(x => x.Id).Column("configurationId").GeneratedBy.Identity();
// Other properties
CheckConstraint("configurationId = 1");
}
}
This will result in the following SQL:
CREATE TABLE Configuration (
configurationId INT IDENTITY NOT NULL,
PRIMARY KEY (configurationId)
CHECK (configurationId = 1)
)
which is pretty similar to the answer at https://stackoverflow.com/a/3967446/273162.
Once you've inserted a row in the table, the identity column will be 1 and the constraint will fail :)