Deploying Sqlite together with ASP.Net MVC and Entity Framework

Of course, you need to install sqlite or deploy the dll together. Yet I keep forgetting that I need to register “.Net Framework Data Provider for Sqlite” You don’t need it on your dev machine, as Sqlite installation register it with your version of .Net machine.config.

If  you not register it, you will have an error “Unable to find the requested .Net Framework Data Provider.”

Add <DbProviderFactories>…</DbProviderFactories> in your web.config (http://www.linuxquestions.org/questions/linux-server-73/sqlite-problems-attempt-to-write-a-readonly-database-611727/)

...
</connectionStrings>

<system.data>
  <DbProviderFactories>
    <remove invariant="System.Data.SQLite" />
    <add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".Net Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
  </DbProviderFactories>
</system.data>

<system.web>
...

I put “…” in order to show where you put the definition.

Another thing that I forget, is to give enough permission to application pool, so IIS process can update sqlite db. Otherwise, you have “sqlite attempt to write a readonly database” error.
Easy and lazy option is to sete the pool’s identity to “Local System”, but I would not recommend it.

Deploying Sqlite together with ASP.Net MVC and Entity Framework