Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a good choice of database for a small .NET application? [closed]

People also ask

What database does .NET use?

NET framework provides three different types of data providers: Sql, OleDb and ODBC. Microsoft is also working on providing a data provider for Oracle database and other Database Management System (DBMS) suppliers may produce their own data providers.

Which database is best for C#?

The simple answer: Microsoft SQL Server.


14/06/2016 Yep... still getting upvotes :-/


17/03/2014 I'm still receiving upvotes for this, be mindful of the date this was originally answered. Though the main three items listed are still entirely viable, the list will tend towards becoming stale. There are further database technologies available that are not listed.


You have a couple of immediately recognisable and free options:

  • SQL Server Express LocalDB
  • SQL Server Compact Edition
  • SQLite

The SQL Server Compact download comes with the ADO.NET provider that you will need to reference in code. The SQLite download might not have it so here is a link:

http://sqlite.phxsoftware.com/

All three use SQL, though likely with a few limitations / quirks. Management Studio works with Compact and LocalDB, whereas with SQLite you will need another UI tool such as SQLite Administrator:

http://sqliteadmin.orbmu2k.de/

There are NoSQL alternatives, such as:

  • Sterling
  • RavenDb

Personally I would avoid using MS Access in the face of other free options. You cannot go wrong with LocalDB, Compact, or SQLite. They are all lovely small databases that run relatively quickly in little RAM - personal preference as to the religious aspects about liking a Microsoft product I suppose :-)

I use Sterling for Windows Phone programming as it is built to use Isolated Storage. I have only seen articles on RavenDb, but I can tell you that it is a JSON based document storage framework.

Not to confuse the situation (go with SQLite, SQL Server Express LocalDB, or SQL Server Compact Edition), but there are other embedded / local databases out there, some are relational others are object-oriented:

  • Embedded Firebird
  • db4o
  • VistaDb
  • SharpHSQL
  • Berkeley DB
  • Eloquera
  • SiaqoDb

Not all of these are free. SQL / LINQ / in-proc support differs across them all. This list is just for curiosity.

There is now also Karvonite, however the code gallery link is broken. When it's live again I'll be looking into this one for WP7 development.


I'd recommend SQLite. We are using it for almost all of the apps we develop where I work.

It's small and compact. It does require a DLL to be in the app directory, but you don't have to have other software installed like Access or SQL Server. Also, as stated by danielkza below, "SQLite is public domain, so you don't have to worry at all about licensing." That can really make a big difference.

You can use System.Data.SQLite or csharp-sqlite to access it in a C# app using the same methods as that of SQL or OleDB.

You will also need an application to edit/manage the database. The best one in my opinion is SQLite Studio. Here are a couple more:
SQLite Admin
SQLite 2009 Pro (bottom of the page)
Update - 7/25/11 - More SQLite apps (question here on SO)

Here's more on SQLite:
SQLite on Wikipedia
Companies that use SQLite

Custom Functions: As an addition, if you are looking in the SQLite Core Functions and don't see one you like, you can create your own custom functions. Here are a couple of examples:
From SO
Anoter example


Firebird embedded can be a good choice

The embedded version is an amazing variation of the server. It is a fully featured Firebird server packed in just a few files. It is very easy to deploy, since there is no need to install the server.

There is some very good dot net drivers


SQL Server Compact if you want to use the official microsoft solution. This has the advantage of being able to use replication with SQL server if you need that sort of thing.

SQLite if you want to somthing very simple small and free. This is what android uses for it's internal databases so it is very well supported and there are very good .NET bindings available.

One distinct advantage of SQLite is that it is cross-platform. So if you wanted to port your application to Mono.NET then you wouldn't have any modifications to make to the database implementation.

I do not like MS Access for this solution but a lot of people have included it in their answer. It is limited due to the proprietary format and platform dependence. It does have it's advantages though. You can manipulate data easily if you have a copy of MS Access, you can build queries graphically and create macros. You can easily integrate it with the rest of MS Office.

Out of all these SQLite would be my recommendation due to it being so compact, well documented and supported by a growing army of fellow developers regardless of platform.

EDIT

I realized that there is another option that everybody here forgot to mention

So long as you don't need relational tables you could use CSV file read as a dataset via ADO.NET. (More of a lulz suggestion than anything else but would be suitable in some cases and doesn't require additional libraries for a MS deployment.