Reputation: 11
I'm trying to setup a Console app with a embedded RavenDb in VS.
I'm apple to store and retrieve documents from the DB. But when i'm visiting the RavenDB studio my DB is not showing up. So what am i doing wrong?
I've writing the following code:
class Program
{
static void Main(string[] args)
{
IDocumentStore documentStore = CreateEmbeddableDocumentStore().Initialize();
using (var session = documentStore.OpenSession())
{
session.Store(new Company { Name = "One" });
session.Store(new Company { Name = "Two" });
session.SaveChanges();
var companies = session
.Query<Company>()
.ToArray();
foreach (var company in companies)
{
Console.WriteLine(company.Name);
}
Console.ReadLine();
}
}
private static EmbeddableDocumentStore CreateEmbeddableDocumentStore()
{
NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(1338);
var store = new EmbeddableDocumentStore()
{
DataDirectory = "Data",
UseEmbeddedHttpServer = true,
Configuration = { Port = 1338 }
};
return store;
}
}
internal class Company
{
public string Name { get; set; }
}
My Console is writing the right output. I can also locate the data file in bin\Debug
But when i visit the RavenDb studio, the DB isn't showing.
How do i setup RavenDB to show my DB?
Upvotes: 0
Views: 208
Reputation: 11
I found what I was looking for by my self.
http://ravendb.net/docs/article-page/3.0/csharp/client-api/setting-up-default-database
Upvotes: 1