【发布时间】:2011-12-17 06:45:38
【问题描述】:
我的情况是这样的:
我有一个在类库 (DLL) 中实现的自定义 RavenDB membership provider。此提供程序需要访问数据库来存储和检索用户和角色信息。我想使用同一个应用数据库来存储会员信息,以避免多一个数据库。
我不知道如何在类库代码中获取对已经初始化的数据库(app数据库)的引用。我想我在这里走错路了...... :)
一些代码:
bool embeddedStore = Convert.ToBoolean(config["enableEmbeddableDocumentStore"]);
if (embeddedStore)
{
_documentStore = new EmbeddableDocumentStore()
{
// Here I'm using the same connection string used by the app.
// This gives me an error when I try to open a session in the DocumentStore.
ConnectionStringName =
config["connectionStringName"]
};
}
else
{
_documentStore = new DocumentStore()
{
ConnectionStringName =
config["connectionStringName"]
};
}
这是 Web.config 中存在的连接字符串:
<add name="RavenDB" connectionString="DataDir = ~\App_Data\Database" />
如何在自定义成员资格提供程序中重复使用相同的数据库?有什么想法吗?
我考虑将类库代码文件移动到 Web 项目中。这样我可以很容易地获得对DocumentStore 的引用,但是代码不会像我想要的那样有条理。
我还尝试使用 2 个 RavenDB 数据库:1 个用于应用程序,1 个用于会员提供程序,但由于我以嵌入式方式运行 RavenDB,我无法使其正常工作。
这些是我迄今为止在尝试过程中遇到的错误:
RavenDB Could not open transactional storage.
Temp path already used by another database instance.
【问题讨论】:
标签: asp.net-membership ravendb class-library multiple-databases