我正在研究CQRS原型实现,并尝试将Jonathan Oliver的事件存储与MS SQL服务器一起使用:
_store = Wireup.Init()
.UsingSqlPersistence("EventStore")
.InitializeDatabaseSchema()
.UsingJsonSerialization()
.Build();
我在app.config中定义了匹配的连接字符串:
<connectionStrings>
<add name="Business.Domain.Repository.Tests.Properties.Settings.EventStore"
connectionString="Data Source=EventStore.sdf;" />
</connectionStrings>
我已经尝试过SQL CE,本地SQL,远程SQL服务器的连接字符串的变体,并且始终会收到此错误:
System.NullReferenceException was caught
Message=Object reference not set to an instance of an object.
Source=EventStore
StackTrace:
at EventStore.Persistence.SqlPersistence.SqlPersistenceFactory.GetDialect() in c:\Projects\Business\Proto1\EventStore\src\proj\EventStore.Persistence.SqlPersistence\SqlPersistenceFactory.cs:line 53
at EventStore.Persistence.SqlPersistence.SqlPersistenceFactory.Build() in c:\Projects\Business\Proto1\EventStore\src\proj\EventStore.Persistence.SqlPersistence\SqlPersistenceFactory.cs:line 46
at EventStore.SqlPersistenceWireup.<>c__DisplayClass4.<.ctor>b__1(NanoContainer c) in c:\Projects\Business\Proto1\EventStore\src\proj\EventStore.Wireup\SqlPersistenceWireup.cs:line 13
at EventStore.ContainerRegistration.Resolve(NanoContainer container) in c:\Projects\Business\Proto1\EventStore\src\proj\EventStore.Wireup\NanoContainer.cs:line 66
at EventStore.NanoContainer.Resolve[TService]() in c:\Projects\Business\Proto1\EventStore\src\proj\EventStore.Wireup\NanoContainer.cs:line 40
at EventStore.PersistenceWireup.Build() in c:\Projects\Business\Proto1\EventStore\src\proj\EventStore.Wireup\PersistenceWireup.cs:line 47
有没有人遇到这个或者知道我做错了什么?我尝试单步执行源代码,但仍不确定为什么存在空引用。 -Steve
答案 0 :(得分:3)
我正在更新现在围绕方言检测的一些错误处理。您需要在连接字符串中添加“providerName”,例如:
<add name="Business.Domain.Repository.Tests.Properties.Settings.EventStore"
providerName="System.Data.SqlServerCe.3.5"
connectionString="Data Source=EventStore.sdf;" />
在连接配置中使用providerName属性允许EventStore知道在连接到数据库实例时使用哪个驱动程序。