我需要验证架构,其中我有一个带有byte []属性(BLOB)的对象。当我运行验证时,我收到OverflowException:“对于Int32,值太大或太小。”
我正在使用NHibernate 3.1.0.400和FluentNHibernate 1.2.0.712 我已经创建了测试项目来检查。这是代码(它在验证时落下):
static void Main(string[] args)
{
var configuration = new NHibernate.Cfg.Configuration();
string connectionString = "some connection string";
Console.WriteLine("Running test with connection string: {0}", connectionString);
Dictionary<string, string> props = new Dictionary<string, string>()
{
{"connection.provider", "NHibernate.Connection.DriverConnectionProvider"},
{"connection.driver_class", "NHibernate.Driver.MySqlDataDriver"},
{"connection.connection_string", connectionString},
{"dialect", "NHibernate.Dialect.MySQL5Dialect"},
};
configuration.AddProperties(props);
var mappings = Fluently.Configure(configuration)
.Mappings(m => m
.FluentMappings.AddFromAssemblyOf<DataResource>()
.Conventions.AddFromAssemblyOf<DataResource>());
var sessionFactory = mappings
.ExposeConfiguration(DoExtendedConfiguration)
.BuildSessionFactory();
}
private static void DoExtendedConfiguration(Configuration configuration)
{
SchemaExport schemaExport = new SchemaExport(configuration).SetDelimiter(";").SetOutputFile("schema.sql");
schemaExport.Create(false, true);
SchemaValidator schemaValidator = new SchemaValidator(configuration);
schemaValidator.Validate();
}
public class DataResource
{
public int Id { get; set; }
public byte[] Value { get; set; }
}
public class DataResourceMap : ClassMap<DataResource>
{
public DataResourceMap()
{
Id(x => x.Id);
Map(x => x.Value);
}
}
答案 0 :(得分:0)
我没有在官员身上找到关于此类错误的任何提及,但在我将FluentNhibernate和Nhibernate更新到最后一个可用版本(通过Nuget)之后,问题得以解决。那套我,所以我将关闭这个问题,好像没有人找到任何其他解决方案,堆栈允许我这样做。