

/ public interface IDbInitialiser : IDisposable / You would normally call this once at application startup

Npoco idatabase updateasync code#
It comprises 2 interfaces: IDbInitialiserĬopy Code /// /// IDbInitialiser is used to manage database initialisation and upgrades. The resulting initialiser is by no means perfect and I am sure that readers will find many ways to improve it however it does the job, it's flexible, automatic and simple to implement. Of course, the initialiser must also have an effective versioning mechanism so that it knows when and where to start applying changes. Thus, any initialiser must be able to handle more complex scenarios beyond simply executing a script. For example, ALTER TABLE cannot be use to drop a column and unlike CREATE TABLE IF NOT EXISTS, there is no similar ALTER TABLE ADD COLUMN IF NOT EXISTS. However, one small limitation is that in some cases, SQLite supports only a subset of standard SQL commands.
Npoco idatabase updateasync full#
IMHO SQLite is a great product even supporting full text searching. However, this solution did not offer any way of automatically keeping the database updated with schema changes and so I created a simple initialization framework which is what this article is about. SQLite was my choice for an in-process database.

I had previously used PetaPoco as a lightweight ORM when working with Umbraco and subsequently found NPoco which had added some nice features including async versions of many methods. This article came about when I was creating a small blog styled web application where EF and SQL Server was just too much overhead, I needed a smaller, lighter, in-process database which I could use with the Microsoft AspNet Identity framework.
