2

i want to use asp MVC with the Embedded RavenDB but it looks like that the DB don't react when debug the MVC application (using VS 2010 and IIS 7.5 Express). For Example in a MVC action i write an object an try to read it from the db in the next step, but the object is not found until the next request. For me it looks like the embedded RavenDB can only listen for request if the MVC application is on idle.

If i changed from embedded to the normal Client/Server it works without problems. I would prefer to use the embedded RavenDB. Maybe someone has some experience with this problem?!

5 Answers5

2

You can use RavenDB embedded without any disadvantages, except that your application startup will take a little longer, when you create the EmbeddableDocumentStore, but nothing to worry about.

The only thing that you should keep in mind is that while you can seemlessly switch from embedded to client/server, there are (very few) cases where you can't go the other way without modifying your code. For example, the lazy-features aren't available in the embedded session because just don't make sense there.

Daniel Lang
  • 6,819
  • 4
  • 28
  • 54
  • If you are on debugg of the mvc app (localhost:53996) could you enter RavenDB-Web-Interface on a differente port (localhost:8080)? I can not enter the RavenDB-Web-Interface while i am debug the mvc app?! I follow the instuction of this page http://www.primaryobjects.com/CMS/Article125.aspx (but i take the embedded RavenDB). – user1176603 Feb 23 '12 at 14:31
  • Yes, just set UseEmbeddedHttpServer to true and set the port as you like. – Daniel Lang Feb 23 '12 at 17:18
  • Thats strange i will set up a new project and check it again, maybe i have a configuration problem. – user1176603 Feb 23 '12 at 18:18
  • In VS i found a configuration Debugging-> Option Settings -> Stop all Process wich was enabled. maybe this was affected the debugging session. – user1176603 Feb 25 '12 at 11:30
2

Easily you can integrate. this might help. http://msdn.microsoft.com/en-us/magazine/hh547101.aspx

Please mark as answer if solved your issue.

Usama Khalil
  • 436
  • 1
  • 4
  • 14
  • I download the code of this tutorial and modified it so that in the create Action i query the DB before insert the bookmark and then after that. Both query return empty list although the new item was added. First i thought it is a caching problem, with WaitForNonStaleResultsAsOfLastWrite the problem seems to be solved. – user1176603 Feb 25 '12 at 11:20
2

The in memory database takes time to do things, so you might be getting stale results.

The nostalequerieslistener from this question should help: RavenDB how to flush?

I had this issue with unit tests, bascially while RavenDB in memory is fast, the small amount of code between inserting and querying for the object is faster.

Community
  • 1
  • 1
Rangoric
  • 2,739
  • 1
  • 18
  • 18
  • Thanks look like this was the main problem. – user1176603 Feb 25 '12 at 11:26
  • I don't see why this should be specific to embedded instances? In addition to that - please be aware that the NoStaleQueriesListener thing is one of the worst things you can do because it pretty much eliminates all the benefits of a document database and worse, it can break a whole application with poor performance – Daniel Lang Feb 25 '12 at 12:32
  • @DanielLang Easy. In the case of the Embedded Database, there is 0 Latency between client and server. With even a 1ms latency, that's a lot of work RavenBD can get done. It adds up to 2ms per round trip, not including the tiny bit of time actually doing the communication. Also since the embedded shares resources much more closely with the app, the app is likely to get to use the minuscule time between save the changes and making sure it's there before RavenDB can do much of anything. – Rangoric Feb 25 '12 at 13:08
1

RavenDB implement the Unit Of Work pattern. Do you call SaveChanges on the document session when you are done?

jgauffin
  • 99,844
  • 45
  • 235
  • 372
1

Yep.

Check this post for a complete sample using best practices:

RavenDB, UnitOfWork and MVC - revisited

Leniel Maccaferri
  • 100,159
  • 46
  • 371
  • 480