"User" is a reserved word on the SQL server, executed by the SQL command:
create table User (Id INT IDENTITY NOT NULL,
UserName NVARCHAR(255) null unique,
primary key (Id))
It is incorrect to name the User table on the SQL server, but it is the right to call it [User].
create table [User] (Id INT IDENTITY NOT NULL,
UserName NVARCHAR(255) null unique,
primary key (Id))
As a solution, you can define different names for tables and columns named with reserved words:
[ActiveRecord("[User]")]
public class User : ActiveRecordLinqBase<User>
{
[PrimaryKey]
public int Id { get; set; }
[Property(Unique = true)]
public string UserName { get; set; }
[HasMany]
public IList<Activity> Activities { get; set; }
}
When using [] around the table name, reserved names are valid. The same applies to relationship columns:
[ActiveRecord]
public class Activity : ActiveRecordLinqBase<Activity>
{
[PrimaryKey]
public int Id { get; set; }
[BelongsTo("[User]")]
public User User { get; set; }
}
Of course, any other name, for example [ActiveRecord("SomeUser")], will work.
source
share