0

Iam using couch-db version 2.2.0

and I want to make crud operations on couchdb database using .Net

so I installed Armchair.Core Nuget Package version 0.11.2

and in order to add d a new document I, followed the code that is mentioned in not finished wiki yet https://bitbucket.org/dboneslabs/arm-chair/wiki/main-api/session-api.md

Database mydatabase = new Database("TestDb",newConnection("http://localhost:5984"));
            using (var session = mydatabase.CreateSession())
            {
                var author = new Person("Jone");
                session.Add(author);// NOTE: If no Id has been assigned before the instance is added to the Session, then ArmChair will assign it. After the object is committed to the database, the revision will then be set onto the instance

                session.Commit();  
            }

but I still getting the error

Object reference not set to an instance of an object.

also mydatabase variable mentioned in previous code has values null for Connection and DataBase Parameters even though i passed them in the constructor as it doesn't connect to couchdb database at all and never tries to create database TestDb

any help please ,are there any wrong calls in my code

oula alshiekh
  • 843
  • 5
  • 14
  • 40

1 Answers1

0

ArmChair connects to an existing database and does not create one.

if you want to create a database, have a look a look at the sample application, in the Autofac registration there is a method which ensures that there is a database created.

https://bitbucket.org/dboneslabs/arm-chair/src/bd4e70d6c51d8b45cfb89eb65ecf81a4ecefb691/samples/todo/Todo.Service/Infrastructure/Modules/DataAccessModule.cs#lines-62

its not the pretty-est of code but works.

dbones
  • 4,415
  • 3
  • 36
  • 52