1

I try migrate one of my databases with FluentMigrator. One of the migrations tries to execute a script. I thought: "I only want to send the DLL to my colleagues" So I packed the SQL-Script into the DLL as a resource-file and now try to access it, but it seems like the Script is not found.

Migration

[Migration(201506021451)]
public class M116_Init_RoleManagement : ForwardOnlyMigration
{
    public override void Up()
    {
        Create.Table("Role")
              .WithIdColumn()
              .WithColumn("Name").AsString().NotNullable();

        Insert.IntoTable("Role").Row(new { Name = "Administrator" });
        Insert.IntoTable("Role").Row(new { Name = "Manager" });
        Insert.IntoTable("Role").Row(new { Name = "SalesManager" });
        Insert.IntoTable("Role").Row(new { Name = "Employee" });

        Create.Table("EmployeeRole")
              .WithIdColumn()
              .WithColumn("EmployeeId").AsInt64().NotNullable()
              .WithColumn("RoleId").AsInt64().NotNullable();
        Execute.Script(Hsk.Migrations.Properties.Resources._2015021451_CreateSalesManagerRoles);
    }
}

Resource File ResourceFile

Projectstructure

ProjectExplorer

Error

201506021451: M116_Init_RoleManagement migrating ========================= Beginning Transaction

Rolling back transaction

Illegal Sign in Path

1 Answer 1

2

The Answer is pretty obvious: Accessing the resource-file via Hsk.Migrations.Properties.Resources._2015021451_CreateSalesManagerRoles returns the content of and not the path to the file.

So the call should look like

[Migration(201506021451)]
public class M116_Init_RoleManagement : ForwardOnlyMigration
{
    public override void Up()
    {
        .
        .
        . 
        Execute.Sql(Hsk.Migrations.Properties.Resources._2015021451_CreateSalesManagerRoles);
    }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.