Error: Creating Content Item in Migrations.cs during WarmUp

Topics: Administration, Troubleshooting, Writing modules
Aug 10, 2012 at 1:52 PM

I have the following method inside one of my Migrations.cs file:

        public int UpdateFrom11()
            var taxonomy = _cms.New("Taxonomy");
            taxonomy.As<TitlePart>().Title = "Sector";
            [Adding a taxonomy field of type Sector...]
            return 12;

If I launch my site from Visual Studio after a rebuild, it will crash on the following line


with the following exception in Orchard.Tokens.Providers.RequestTokens Evaluate() method on line 23:

{"Object reference not set to an instance of an object."}

because the following returns null:


If I stop the debugger, manually revert the Orchard_Framework_DataMigrationRecord Version to 11 in the database and start over, the module will this time not try to update automatically but rather I will have a warning message in the dashboard saying my module needs to be updated. When I update manually from the dashboard everything will work fine.

Am I doing something wrong trying to add Content Items from Migrations.cs? Or is this an Issue I should report?

Aug 12, 2012 at 5:54 PM

I think you should file a bug, yes.