gpt4 book ai didi

ravendb - RavenB 选择数据库

转载 作者:行者123 更新时间:2023-12-02 08:44:49 25 4
gpt4 key购买 nike

var store = new DocumentStore()
{
Url = @"http://localhost"
};
store.Initialize();


Blog blog = new Blog()
{
Title = "Hello RavenDB",
Category = "RavenDB",
Content = "This is a blog about RavenDB",
Comments = new BlogComment[]{
new BlogComment() { Title = "Unrealistic", Content= "This example is unrealistic"},
new BlogComment() { Title = "Nice", Content= "This example is nice"}
}
};

using (IDocumentSession session = store.OpenSession())
{
session.Store(blog);
session.SaveChanges();
}

以上代码将数据保存到默认数据库中。 (这是一个网络应用程序。)但我希望它将数据保存到我创建的另一个数据库 raven management studio(网页)。我在哪里指定数据库名称?另外请告诉我如何在配置文件中保存带有数据库名称的连接字符串。这就是我将其保存到没有数据库名称的配置文件的方式

<connectionStrings>
<add name="Local" connectionString="DataDir = ~\Data"/>
<add name="Server" connectionString="Url = http://localhost:8080"/>
</connectionStrings>

最佳答案

您的所有问题都在 documentation 中得到了解释:

new DocumentStore 
{
ConnectionStringName = "Local"
}
<connectionStrings>
<add name="Local" connectionString="DataDir=~\Data;Database=MyDatabaseName"/>
<add name="Server" connectionString="Url=http://localhost:8080;Database=MyDatabaseName"/>
</connectionStrings>

关于ravendb - RavenB 选择数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13278583/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com