我在一个项目中使用FluentMigrator,当我试图在现有的表中添加一个新的xml列时,数据库中的更新遇到了一些问题。
我在用:
migrator是通过使用SqlServer2012ProcessorFactory配置的。
在我的迁移中,我有以下代码:
[Migration(201502271030)]
public class _201502271030_AddLineItemAndSummariesColumn : Migration
{
public override void Up()
{
Create.Column("InitialDiscount").OnTable("LineItems").InSchema(Const.Schema.DeskReview)
.AsDecimal(11, 2).Nullable().WithDefaultValue(false);
Create.Column("AcceptedDiscount").OnTable("LineItems").InSchema(Const.Schema.DeskReview)
.AsDecimal(11, 2).Nullable().WithDefaultValue(false);
Create.Column("BodyshopName").OnTable("LineItems").InSchema(Const.Schema.DeskReview)
.AsString(Const.Length.Name).Nullable().WithDefaultValue(false);
Create.Column("State").OnTable("LineItems").InSchema(Const.Schema.DeskReview)
.AsString(Const.Length.Name).Nullable().WithDefaultValue(false);
Create.Column("City").OnTable("LineItems").InSchema(Const.Schema.DeskReview)
.AsString(Const.Length.Name).Nullable().WithDefaultValue(false);
Create.Column("ExternalDataXml").OnTable("WorkQueueItems").InSchema(Const.Schema.DeskReview)
.AsXml(int.MaxValue).Nullable().WithDefaultValue(false);
Create.Column("Version").OnTable("WorkQueueItems").InSchema(Const.Schema.DeskReview)
.AsInt32().Nullable().WithDefaultValue(0);
}
public override void Down()
{
}
}但是,当我运行这段代码时,我得到了一个例外:
异常详细信息: System.NotSupportedException:不支持的DbType 'Xml‘
Line 15: try
Line 16: {
Line 17: base.ApplyMigrationUp(migrationInfo, useTransaction);
Line 18: }
Line 19: catch (Exception e)有没有人有过这样的问题,或者知道出了什么问题?
发布于 2015-03-01 21:35:29
问题是:我试图用以下方法指定XML的最大长度:
.AsXml(int.MaxValue)在以下位置:
Create.Column("ExternalDataXml").OnTable("WorkQueueItems").InSchema(Const.Schema.DeskReview)
.AsXml(int.MaxValue).Nullable().WithDefaultValue(false);我刚删除了参数,它起作用了。
所以,代码是这样的:
Create.Column("ExternalDataXml").OnTable("WorkQueueItems").InSchema(Const.Schema.DeskReview)
.AsXml().Nullable();多蠢的问题..。但没问题。
https://stackoverflow.com/questions/28768651
复制相似问题