Summary of how to use the EntlibContrib SQLite provider with Enterprise Library 3.1 (May 2007) and ASP.NET
Information and download of System.Data.SqLite:
Enterprise Library 3.1 (May 2007):
EntLibContrib Project at codeplex:
I've extolled the virtues of the amazing SQLite database engine a number of times here (just use our Search widget with "SQLITE") so I won't go into much detail about it. Here are a few bullet points, though:
- Complete ADO.NET 2.0 Implementation
- Supports the Full and Compact .NET Framework as well as native C/C++
- Completely portable database files
- Incredibly fast, faster than most every other embedded database, including Sql Server Mobile
- Encryption Support
- Full Text Search
- Visual Studio 2005 Design-Time Support
- Single file redistributable under 500kb -- nothing to "install"!
- Extensive SQL support
- User-Defined Functions & Collating Sequences, Triggers
- Full Source Included. 100% Free
You can thank my friend Robert Simpson for all this effort and contribution. In sum, SQLite is very fast, requires no configuration or installation (only that the assembly be present), and implements most all of the SQL 92 spec. With the ADO.NET Provider, you are dealing with datareaders, DataSets and all the familiar programming tools you are used to. The SQL syntax is a bit of a variant from T-SQL, but the differences are quite minor.
At Codeplex, there is a Enterprise Library "contrib" project with a number of enhancements written by users like you and me. One in particular that caught my attention was the SQLite provider, written by Ken Scott http://freqken.net/.
The solution here shows how to wire up your Entlib configuration to use the ADO.NET 2.0 System.Data.SqLite engine with Enterprise Library 3.1
First you will need the required EntLib and Contrib assemblies:
Then, you'll set up your configuration, which can be done with the EntLib Configuration Add-on from within Visual Studio:
My sample config looks like this:
Finally, I've got two sample classes that I ripped right out of the test fixtures from the Contrib project, and massaged to fit this demo:
And that's it! The Database object has most of the same familiar methods that are present for all the other Providers. The only thing you don't have is stored procedures.
However, based on all the "stored procs are evil" diatribe I've listened to and read, that could be a good thing!
Note that I am doing a string Replace on the "dbPath" string with Server.MapPath and the name of the database file to make this more portable for ASP.NET.