【发布时间】:2014-12-29 22:05:23
【问题描述】:
在 Entity Framework 6.1 中,在基于 C# 代码的迁移(使用 System.Data.Entity.Migrations.DbMigration)中,当使用 DbMigration.AlterStoredProcedure 方法更改存储过程定义时,添加或修改smallmoney 类型的存储过程参数(在 SQL Server 2012 上)?
例如,如果我有一个修改现有 SQL Server 存储过程的迁移方法,该存储过程采用三个参数,类型分别为 int、varchar 和 smallmoney:
public partial class MyCustomMigration : DbMigration
{
public override void Up()
{
this.AlterStoredProcedure("dbo.EditItem", c => new
{
ItemID = c.Int(),
ItemName = c.String(),
ItemCost = /* What goes here to represent the smallmoney SQL Server type? */
},
@" (New sproc body SQL goes here) ");
}
// ...
}
【问题讨论】:
-
您可以尝试使用
ItemCost = c.Decimal(storeType: "smallmoney")... 实际上您可以在这里使用任何方法,例如c.Int()或c.Double()或任何其他内容,直到您明确指定storeType: "smallmoney" -
如何为字符串变量指定长度的相关问题:stackoverflow.com/questions/7341783/…
标签: c# sql-server entity-framework entity-framework-6.1