我有以下代碼來創建一個內存中的SQLite數據庫來進行測試:的SQLite數據庫產生不可爲空列
Configuration config = null;
FluentConfiguration fluentConfiguration = Fluently.Configure().Database(SQLiteConfiguration.Standard.InMemory().ShowSql()
).Mappings(m =>
{
m.FluentMappings.AddFromAssemblyOf<ReturnSourceMap>();
m.HbmMappings.AddFromAssemblyOf<ReturnSourceMap>();
m.FluentMappings.AddFromAssemblyOf<EchoTransaction>();
}).ExposeConfiguration(c => config = c);
ISessionFactory sessionFactory = fluentConfiguration.BuildSessionFactory();
_session = sessionFactory.OpenSession();
new SchemaExport(config).Execute(true, true, false, _session.Connection, Console.Out);
這似乎很好地工作對於大多數事情,但不幸的是它將所有列創建爲不可爲空。
比如我有兩個類:
InternalFund
和ExternalFund
。兩者都從Fund
繼承,並且都堅持到同一個表。
ExternalFund
有一列Manager_ID
,InternalFund
沒有。不幸的是,這意味着我不能堅持InternalFund
,因爲它會拋出一個SQL異常。
我不需要我的測試的參照完整性,所以如果我可以使所有列都可以爲空,我會很高興。
有誰知道如何做到這一點?
感謝
斯圖