DalSoft / dalsoft-website-comments

0 stars 0 forks source link

blog/index.php/2012/04/12/mvc-get-ravendb-up-and-running-in-5-minutes-using-ninject/ #19

Open utterances-bot opened 1 week ago

utterances-bot commented 1 week ago

ASP.NET MVC - Get RavenDB up and running in 5 minutes using Ninject

How to get the NoSQL database RavenDB working with ASP.NET MVC and dependency injection.

https://www.dalsoft.co.uk/blog/index.php/2012/04/12/mvc-get-ravendb-up-and-running-in-5-minutes-using-ninject/

DalSoft commented 1 week ago

Legacy Comments

Jacob Reimers says: April 25, 2012 at 4:52 pm Can’t seem to find RavenDBNinjectModule.cs code.


DalSoft says: April 25, 2012 at 5:19 pm https://raw.github.com/gist/2360124/c8162b82d5cde97dce88d7a6a165035812e542fc/RavenDBNinjectModule


Naveen says: April 25, 2012 at 5:56 pm Since you have real time experience, can you share your experience using RavenDB? (why custom chose this DB, how different it is from SQL Server or Oracle, some highlights about the issues you face with RevenDB )


DalSoft says: April 26, 2012 at 11:19 am Hi Naveen,

The post was to show that it’s trivial to setup RavenDB. Rather than RavenDB vs SQL server etc. My experience is RavenDB is definitely a great tool to have on your tool belt. I’m not in the camp that says one is a replacement for the other, it’s about picking the right tool for the job. Development wise you don’t have ORM and mappings concerns which make for a frictionless workflow IMO.

There is a good write up over at stack exchange http://programmers.stackexchange.com/questions/90877/document-database-versus-relational-database-how-to-choose


Gertie says: July 19, 2016 at 3:54 am Posts like this brigthen up my day. Thanks for taking the time.


Ethan says: April 26, 2012 at 1:04 am Get a error stating that

Error 1 ‘Ninject.IKernel’ does not contain a definition for ‘Get’ and no extension method ‘Get’ accepting a first argument of type ‘Ninject.IKernel’ could be found (are you missing a using directive or an assembly reference?) C:\Work\RavenDB\Raven\Raven\App_Start\RavenDBNinjectModule.cs 25 73 Raven

on Line

Bind().ToMethod(context => context.Kernel.Get(IDocumentStore).OpenSession()).InRequestScope();


DalSoft says: April 26, 2012 at 11:36 am Hi Ethan,

Try adding using Ninject; to the code. There is a full working example on GitHub https://github.com/DalSoft/RavenDBInFiveMinutes


Bjarkeck says: August 21, 2012 at 12:25 pm Thank you 🙂 That fixed it for me


Bjarkeck says: August 21, 2012 at 12:44 pm Hi Dalsoft thank your for your guide.

I get this error when initialising the page for the first time:

“Cannot load Counter Name data because an invalid index was read from the registry” Linje 21: return documentStore.Initialize();

I Used MVC 4, and here is what i did differently: i got an error when installing RavenDb Embedded with the console, so i did it from NuGet, and that worked fine.

My Raven.Studio.xap was not located in \lib\net40\ but in \tools

Other then that, everything was the same.

Hope you can help 🙂


DalSoft says: August 21, 2012 at 1:17 pm Hi Bjarkeck,

If you put your code on GitHub or something, I’ll take a look at it for you.

Darran


jacqueline says: May 20, 2012 at 8:49 am Good post. I referred to it in a blogpost. Thanks!


dhyah says: June 6, 2012 at 8:28 pm It’s better to write a implement with sqlserver , so we can switch different database in web.config. that’ the benefit using Ninject .


Avin says: July 3, 2012 at 7:03 am dude,

I went through ur youtube video.Sad to say, it lacks sound. Did n’t anybody reported this before?

Regards, Avin


DalSoft says: August 21, 2012 at 1:19 pm Hi Avin,

The video doesn’t have any commentary this time. Although it does show step by step how I created the example.


Derick says: January 9, 2013 at 5:50 am I’m using MVC4 and I was using RavenDB 1 and this all worked great. I upgraded to RavenDB 2.0 and I am getting an HttpListenerException on documentStore.Initialize() saying “The process cannot access the file because it is being used by another process”. I’m wondering if anyone else has had this issue.


DalSoft says: February 17, 2013 at 7:55 pm Sounds like the port is clashing with another port on your machine. Try changing the port does it work?

NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(8080);

Also try removing that line completely, but this will stop the RavenDB Studio running.


Nikolay says: February 10, 2013 at 4:55 am Hi Darren,

Very neat post! I have one question: Ayende suggests that the Session object needs to be destroyed after it’s been used. I see, you open session upon http request. However, I don’t see a place where the the session is getting destroyed. Any advice on that?


DalSoft says: February 17, 2013 at 8:04 pm This Ninject binding:

Bind().ToMethod(context => context.Kernel.Get(IDocumentStore).OpenSession()).InRequestScope();

Is perfect for RavenDB as it means give me only one session per web request. More information on Ninject’s scoping https://github.com/ninject/Ninject.Web.Common/wiki/InRequestScope


Marc Brooks (@IDisposable) says: February 27, 2013 at 2:15 am One suggestion would adding the XAP as a linked resource instead of copying it so any update-package will do the right things:

Right click the project, Add/Add Existing Item.. dialog, navigate down to the packages directory and back up to RavenDB/tools and then select the XAP (single click), then click the drop-arrow ON the Add button and choose Add As Link. Poof, now the single xap file is what is referenced and deployed (make sure the properties of the xap is Content).


DalSoft says: February 27, 2013 at 11:00 am What a great idea, thank for sharing. I’ll will make the change to the package soon.


Mistic6 says: February 28, 2013 at 6:20 pm Hello DalSoft,

Have you tried this in a MVC 4 / 4.5 Framework app?


DalSoft says: March 5, 2013 at 1:46 pm Yes it works fine