using reserved word as entity name

c#, nhibernate, sql-server

Solution

The correct way to deal with this in NHibernate is using SQL Quoted Identifiers.

Just wrap the table or column name in backticks and the `Dialect` will take care of using the right symbol for your database.

To make things easier, NHibernate provides a configuration setting that does this for you: set `hbm2ddl.keywords="auto-quote"` in an xml config file, or call `AutoQuoteKeywords()` when using loquacious.

Problem

I'm using NHibernate mapping by code with naming conventions to map my entities. Now I have following error ``` SQL error - Incorrect syntax near the keyword 'User'.: ``` I know this is reserved word and I'm wonder how can I use this name (User) as entity name in mapping by conventions.

Original source

Related problems