|
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";
_cms.Create(taxonomy);
_cms.Flush();
[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
_cms.Create(taxonomy);
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:
_workContextAccessor.GetContext()
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?
|