mrahhal/Migrator.EF6

Error Generating Migrations

Closed this issue · 4 comments

I noticed an error when generating migrations which caused me to be unable to run the migration generated. When I try I get this error:

Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "MyProject.Migrations.MyMigrationName.resources" was correctly embedded or linked into assembly "MyProject" at compile time, or that all the satellite assemblies required are loadable and fully signed.

I notice then, in the initial migration generated by your tools the designer file looks like this:

public sealed partial class InitialCreate : IMigrationMetadata
{
        string IMigrationMetadata.Id
        {
            get { return "201610061952137_InitialCreate"; }
        }

        string IMigrationMetadata.Source
        {
            get { return null; }
        }

        ...
}

Then in my second migration it looks like this:

private readonly ResourceManager Resources = new ResourceManager(typeof(UpdatedEntities));

string IMigrationMetadata.Id
{
      get { return "201610102027102_UpdatedEntities"; }
}

string IMigrationMetadata.Source
{
      get { return Resources.GetString("Source"); }
}

So the error is clear here, it's referencing resource manager that I am not using, removing that line and setting the IMigrationMetadata.Source to return null, as in the original migration fixed the problem. But it seems to be an error in generating it.

As an aside, in the package manager to download your package, only 1.0.4 and 1.0.6 show up. You can update project.json with 1.0.5 and it works, but it doesn't show in the package explorer UI.

Yes something is definitely wrong here. The string IMigrationMetadata.Source property should always be returning null. Don't worry about the private readonly ResourceManager Resources = new ResourceManager(typeof(UpdatedEntities)); line, I should be removing it from all the files but it's a bug, it's not harmful though.

So it's the problem of IMigrationMetadata.Source not returning null. This worked for you before, right? Anything you did differently in this project?

I think I can guard against this in all cases and check if there's a "Source" resource along with the "Target" resource. But I'm curious to know why the "Source" property is not returning null in your case.

As an aside, in the package manager to download your package, only 1.0.4 and 1.0.6 show up. You can update project.json with 1.0.5 and it works, but it doesn't show in the package explorer UI.

Yeah I do that sometimes when I release 2 versions in close intervals. 1.0.5 is still there but it's just hidden. 1.0.6 includes 1.0.5, I guess it just makes it easier to read.

I checked the EF6 source, it seems it does add a "Source" resource sometimes. I'll make a fix in all cases.

Fixed in 8204b0b, included in 1.0.7.

Thanks for reporting this!

Wonderful, thanks!