我首先使用Fluent nHibernate代码,我有Nullable列,然后更改为.Not.Nullable() 但我的专栏仍然是Nullable
这是我的配置
public override void Load()
{
Bind<ISessionFactory>().ToMethod(x =>
{
var factory = Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2008.ConnectionString
(c => c.FromConnectionStringWithKey("DefaultConnection")))
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<Users>()
.Conventions.Add(PrimaryKey.Name.Is(p => "Id"), ForeignKey.EndsWith("Id"))
.Conventions.Setup(c => c.Add(AutoImport.Never())))
.ExposeConfiguration(cfg => new SchemaUpdate(cfg).Execute(true, true));
return factory.BuildSessionFactory();
}).InSingletonScope();
}
答案 0 :(得分:2)
AFAIK SchemaUpdate不会触及现有列,因为它不会处理边缘情况,例如如果列已经包含空值会发生什么?
您的选择: