problem with orchard storage : specified table does not exist

Topics: Customizing Orchard, Writing modules
Jun 12, 2011 at 6:22 AM

Cross posted this here:

http://social.msdn.microsoft.com/Forums/en-US/orchardsupport/thread/f6041651-bbd6-4e23-9830-92ce90a58f29

 

I'm just trying to write a module, but I'm having quite a few problems getting the storage to work!

 

Here is my code:

 

//My Model
public class QuizRecord
{
        public virtual int Id { get; set; }
        public virtual string Title { get; set; }
        public virtual string Description { get; set; }
        public virtual int MaxMinutes { get; set; }
}
//my full migration class
public class Migrations : DataMigrationImpl
    {
        public int Create()
        {
            SchemaBuilder.CreateTable("QuizRecord",
                table => table
                    .Column<int>("Id", a => a.PrimaryKey().Identity())
                    .Column<string>("Title", a => a.NotNull())
                    .Column<string>("Description", a => a.NotNull())
                    .Column<int>("MaxMinutes", a => a.NotNull())
                    );
            return 1;
        }
    }

//THE EVIL problem line:
//HomeController
 public ActionResult Index()
        {
            _repo.Create(new QuizRecord { 
                 Title = "Quiz1", 
                  Description = "long quiz", 
                  MaxMinutes = 20 });
      }


 

The _repo.Create is the problem line, when I debug VS tells me the outer exception

(NHibernate GenericADO Exception) {"could not insert: [QuizzerMock.Models.QuizRecord][SQL: INSERT INTO QuizzerMock_QuizRecord (Title, Description, MaxMinutes) VALUES (?, ?, ?)]"}

Hitting continue gives me the inner exception on the page:

(SqlCe Exception) "The specified Table does not exist. [QuizzerMock_QuizRecord] "

I tried enabling/disabling the feature a couple of times? Why doesn't the table exist? What am I doing wrong?

Coordinator
Jun 12, 2011 at 1:59 PM

Maybe your migration has already been run previously, so you might need to create the table in an UpdateFrom1() method instead. Or you can delete the current migration version in Orchard_DataMigrationRecord table for your module.

Jun 12, 2011 at 5:34 PM

Excellent! Thanks! 

Was such an idiot, I just didn't think I could use web matrix to open the SDF and just edit the database myself.

I deleted the record from the Orchard_Framework_DataMigrationRecord table. Also deleted the QuizRecord table which had a definition from an earlier migration class I wrote.

I did have to goto modules in the dashboard and orchard asked to me update the module, when I did. Everything worked out fine. 

On to the more difficult things now!