I have an existing Episerver-based website and it doesn't update the structure of the published pages when it is changed.
I have a huge amount of published pages derived from BasePage. Then I have to add a new block to that page:
public abstract class BasePage : PageData
{
[Display(Name = "SomeBlock")]
public virtual SomeBlock SomeBlock { get; set; }
}
public class SomeBlock : BlockData
{
[CultureSpecific]
[Display(Name = "Field1")]
public virtual string Field1 { get; set; }
}
I am trying to update the page in Scheduled Job. The code would look like
BasePage writeablePage = (BasePage)basePage .CreateWritableClone();
if (basePage.SomeBlock == null)
basePage.SomeBlock = new SomeBlock ();
if (string.IsNullOrWhiteSpace(basePage.SomeBlock.Field1))
{
basePage.SomeBlock.Field1 = "Some Text";
}
DataFactory.Instance.Save(writeablePage, SaveAction.Publish, AccessLevel.NoAccess);
But this approach doesn't work. I have tried to play with "SaveAction" but with no effect
Update: I am using the DB from the staging environment and it looks like the problem with versioning (Let's say I have 1.* assembly locally but there is 2.* on the staging server)
The issue was caused by the lower version of local Assembly then on the staging server which DB was used.
The local solution: