I am using DbUp to handle upgrading my SQL database but also want to use it to handle upgrading an Umbraco CMS.
I am using the DbUp extension method WithScriptsAndCodeEmbeddedInAssembly() to perform the upgrades, but I need to inject the Umbraco ContentTypeService into my DbUp code file:
public class Code0001(IContentTypeService contentTypeService) : IScript
{
private readonly IContentTypeService _contentTypeService = contentTypeService;
public string ProvideScript(Func<IDbCommand> dbCommandFactory)
{
// ...perform CMS updates here...
}
}
I get the following error when trying to run this upgrade:
An exception of type 'System.MissingMethodException' occurred in [DLL Name] but was not handled in user code: 'Cannot dynamically create an instance of type [Embedded Code File]. Reason: No parameterless constructor defined.'
I can't have a parameterless constructor as I need to inject the Umbraco dependency. How would I get this working?