[MappingException: No persister for: ]

Topics: General
Jun 18, 2014 at 4:23 PM
Edited Jun 18, 2014 at 5:02 PM
[MappingException: No persister for: My.User.Models.UserActivity]

Not sure what I am doing wrong. I don't want a content part or part record, I just want to create, insert and update my own database table.
namespace My.User.Models
{
    public class UserActivity
    {
        public virtual int ID{get; set;}
        public virtual int ApplicableRestriction{get; set;}
        public virtual string ActiveUrl{get; set;}
        public virtual int UserId{get; set;}
        public virtual string SchoolCode{get; set;}
        public virtual DateTime Initiated{get; set;}
        public virtual DateTime Expires{get; set;}
        public virtual int IP{get; set;}
        public virtual bool Denied {get; set;}
    }
}
Migrations
    public class Migrations : DataMigrationImpl
    {
        private readonly IRoleService _roleService;
        private readonly IRepository<UserActivity> _userActivity;

        public Migrations(IRoleService roleService, IRepository<UserActivity> userActivity)
        {
            _roleService = roleService;
            _userActivity = userActivity;
        }

        public int Create()
        {
            SchemaBuilder.CreateTable("UserActivity", table => table
                .Column<int>("ID", column => column.PrimaryKey().Identity())
                .Column<DateTime>("Initiated")
                .Column<string>("SchoolCode")
                .Column<int>("UserId")
                .Column<string>("ActiveUrl")
                .Column<int>("ApplicableRestriction")
                .Column<DateTime>("Expires")
                .Column<int>("IP")
                .Column<bool>("Denied")
                );

            UserActivity newActivity = new UserActivity()
            {
                Expires = DateTime.Now,
                ActiveUrl = "",
                ApplicableRestriction = -1,
                Initiated = DateTime.Now,
                SchoolCode = "",
                UserId = -1
            };

            _userActivity.Create(newActivity);
_userActivity.Create(newActivity); Explodes with the mentioned error.

Any help is appreciated.
Jun 18, 2014 at 5:39 PM
For giggles,

I took the relationSample from http://docs.orchardproject.net/Documentation/Creating-1-n-and-n-n-relations and included it into my project..

the RelationSample was succesfull at creating the states in the state table.

I cannot for the life of me identify a difference in code between the two..

Is it possible the issue is caused due to my name space having an extra level?
Coordinator
Jun 18, 2014 at 7:38 PM
You need to register a Repository for the record inside a handler class. It's in the documentation page you are linking.
Jun 18, 2014 at 8:10 PM
For RelationSample, StateRecord I see no reference to adding a hander or registering the repository.

When I try
    public class UserActivityHandler : ContentHandler
    {
        public UserActivityHandler(IRepository<UserActivity> repository)
        {
            Filters.Add(StorageFilter.For(repository));
        }
    }
I receive an error saying there is no implicit conversion from UserActivity to contentPartRecord,

as in both my cases and the example for StateRecord, I do not inherit contentpartrecord.
Jun 18, 2014 at 8:13 PM
Maybe it is worth mentioning, I am not referencing this in any content part either.. Dunno.
Jun 18, 2014 at 8:35 PM
Inheriting from ContentPartRecord

blew up even further down the line saying not-null property references a null or transient value my.User.Models.UserActivity.ContentItemRecord
Jun 18, 2014 at 8:41 PM
this more closely represents what I am doing.

http://weblogs.asp.net/bleroy/storing-non-content-data-in-orchard
Jun 18, 2014 at 8:51 PM
Found my issue..

public virtual int ID{get; set;}


should have been

public virtual int Id{get; set;}


I don't want to play with the other kids in the sandbox anymore.