Over the years, I’ve looked into using Berkeley DB for my own C# applications because it has a solid reputation as a very fast, reliable key/value database. Every time I’ve walked away disappointed with the .NET API wrapper—until now. My interest was renewed a few days ago when I noticed an item on StackOverflow comparing SQLite performance to Berkeley DB. Since acquiring Berkeley DB, Oracle has been busy making it better, including adding better support for the .NET development community.
WARNING: read and understand the license terms and conditions for Berkeley DB before you choose to use it.
I began this most recent review by downloading the MSI Windows installer. DO NOT DO THIS! When I tried to compile the VS2010 solutions (see below), I got all kinds of errors. Next I tried downloading the 45MB zip file. This worked like a charm, except the .NET examples projects had a broken reference which was easily fixed. Follow these steps and you’ll be up and running your .NET app using Berkeley DB in no time.
- Download db-5.2.28.zip file.
- Right click the zip file and select Properties and click the "Unlock" button. This will unlock and make usable all the files in the zip file for your local machine. DO NOT SKIP this step.
- Extract the contents of the zip file to a directory, e.g. C:\Code so that you will have a C:\Code\db-5.2.28 folder.
- In that db-5.2.28 folder, you will find a build_windows folder. This will be your home for the next steps. Be sure to follow them in order.
- Open Berkeley_DB_vs2010.sln
- build debug win32 and x64
- build release win32 and x64
- Open Berkeley_DB_examples_vs2010.sln
- build debug win32 and x64
- build release win32 and x64
- Open BDB_dotNet_vs2010.sln (allow default conversion)
- build debug win32 and x64
- build release win32 and x64
- Open BDB_dotNet_examples_vs2010.sln
- In each project, delete the missing reference to "db_dotnet" and add reference to ..\AnyCPU\Release\libdb_dotnet52.dll
- build debug win32 and x64
- build release win32 and x64
That’s it. Now you can run the example projects and you have a .NET library and x86 (Win32) and x64 binary engines for that library to use. Enjoy!