Question

I would like to use Sqlite database in my Monotouch app. From http://docs.xamarin.com/recipes/ios/data/sqlite i see two options.

  1. Sqlite-net
  2. ADO.NET

Doing research i found that Sqlite-net is easy to use, works on both ios and android but does not support foreign key concept. My need is to have relations in my db. Student table is linked to classes, professor, assignments table. Not so complicated!!! Does Sqlite-net supports such relations? Which one is better choice Sqlite-net or ADO.Net. Appreciated... Thanks

Was it helpful?

Solution

ADO.Net doesn't give you out of the box support for relationships either. It only gives you raw classes like SQLCommand and SQLDataReader.

I would highly recommend sqlite-net, as it is a huge timesaver in being an ORM.

You can setup foreign keys by calling manual SQL statements in sqlite-net, which is the same you would do with ADO.Net anyway.

So with sqlite-net, there are several ways you could setup your database:

  1. Call sqlite-net's APIs for creating tables based on your C# classes, then add things it doesn't support with manual SQL like foreign keys and indexes
  2. Include an empty database with your app with the full schema already setup
  3. Create the entire database with a raw SQL script

I tend to go with option #2 if I want full control of the database schema (and it's a little easier to include a database file I made in SQLite Expert). sqlite-net should work with an existing database just fine.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top