Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi, I am using the 7.7.7 version and I wanted to add columns for one of my custom tables in my Umbraco project. As I did that before in 7.6.8, I copy the code I have:
public class TestFeatureMigration : MigrationBase
public TestFeatureMigration (ISqlSyntaxProvider sqlSyntax, ILogger logger) : base(sqlSyntax, logger)
public override void Down()
public override void Up()
And when I call this class using an ApplicationEventHandler, I get this weird exception:
Error creating type TestFeatureMigration
System.MissingMethodException: No parameterless constructor defined for this object.
So it's a reflection issue and umbraco is expecting an empty constructor for TestFeatureMigration. The problem is that MigrationBase is requesting a constructor with those parameters.
Is it a breaking change between 7.6 and 7.7 ? Am I using MigrationBase wrong ?
I found the issue, it looks like it's not possible to have 2 classes inheriting from MigrationBase at the same time in the same project.
you can have multiple classes inheriting from migration base, it was probibly more likely that the default constructor when you overrode the class was protected.
this catches me out all the time :( when you inherit the class in visual studio the default constructor will be protected.
public class Testmigration : MigrationBase
protected Testmigration(ISqlSyntaxProvider sqlSyntax, ILogger logger) : base(sqlSyntax, logger)
you just need to change protected to public.
Thank you Kevin! I've been scratching my head for the past few hours trying to figure out what was going wrong... and yup, the constructor was protected! (facepalm)
That makes sense, it explains the reflection error, thanks mate
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted