C# FluentMigrator-执行资源文件/脚本
我尝试使用FluentMigrator迁移我的一个数据库。 其中一个迁移尝试执行脚本。 我想:“我只想把DLL发给我的同事” 因此,我将SQL脚本作为资源文件打包到DLL中,现在尝试访问它,但似乎找不到该脚本 迁移C# FluentMigrator-执行资源文件/脚本,c#,sql,dll,fluent-migrator,C#,Sql,Dll,Fluent Migrator,我尝试使用FluentMigrator迁移我的一个数据库。 其中一个迁移尝试执行脚本。 我想:“我只想把DLL发给我的同事” 因此,我将SQL脚本作为资源文件打包到DLL中,现在尝试访问它,但似乎找不到该脚本 迁移 [Migration(201506021451)] public class M116_Init_RoleManagement : ForwardOnlyMigration { public override void Up() { Create.Ta
[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);
}
}
资源文件
项目结构
错误
201506021451:M116初始角色管理迁移=========================
开始交易
回滚事务
非法登录路径
答案很明显: 通过
Hsk.Migrations.Properties.Resources.访问资源文件。\u 2015021451\u CreateSalesManagerRoles
返回文件的内容,而不是文件的路径
所以这个电话应该是这样的
[Migration(201506021451)]
public class M116_Init_RoleManagement : ForwardOnlyMigration
{
public override void Up()
{
.
.
.
Execute.Sql(Hsk.Migrations.Properties.Resources._2015021451_CreateSalesManagerRoles);
}
}