У меня есть таблицы типа
Пользователи (UserId, Имя пользователя, Пароль, CreatedOn, CreatedBy)
Роли (RoleId, RoleName, Описание, Создано, Создано)
UserRoleMap (UserRoleMapId, UserId, Идентификатор роли, CreatedOn, CreatedBy)
Это мои сущности:
[ActiveRecord(Table="Users")]
public class User:ActiveRecordBase<User>
{
[PrimaryKey(Generator = PrimaryKeyType.Identity, Column = "RoleId")]
public virtual int UserId { get; set; }
[Property(Column="Username")]
public virtual string Username { get; set; }
[Property(Column = "Password")]
public virtual string Password { get; set; }
[Property(Column="CreatedBy")]
public virtual string CreatedBy { get; set; }
[Property(Column="CreatedOn")]
public virtual DateTime CreatedOn { get; set; }
[HasAndBelongsToMany(Table="UserRoleMap",ColumnKey="UserId")]
public IList<Role> Roles { get; set; }
}
[ActiveRecord(Table = "Roles")]
public class Role : ActiveRecordBase<User>
{
[PrimaryKey(Generator = PrimaryKeyType.Identity, Column = "RoleId")]
public virtual int RoleId { get; set; }
[Property(Column = "RoleName")]
public virtual string RoleName { get; set; }
[Property(Column = "Description")]
public virtual string Description { get; set; }
[Property(Column = "CreatedBy")]
public virtual string CreatedBy { get; set; }
[Property(Column = "CreatedOn")]
public virtual DateTime CreatedOn { get; set; }
[HasAndBelongsToMany(Table = "UserRoleMap", ColumnKey = "RoleId")]
public IList<User> Users { get; set; }
}
[ActiveRecord(Table="UserRoleMap")]
public class UserRoleMap:ActiveRecordBase<UserRoleMap>
{
[PrimaryKey(Generator = PrimaryKeyType.Identity, Column = "UserRoleMapId")]
public virtual int UserRoleMapId { get; set; }
[BelongsTo(Column="UserId",Table="Users")]
public virtual User UserId { get; set; }
[BelongsTo(Column = "RoleId", Table = "Roles")]
public virtual Role RoleId { get; set; }
}
Я получаю эту ошибку:
ActiveRecordSample.Tests.