Since SQLite is a relational database, it needs to know some basic information about how to create the tables that will store our objects. This is done using attributes, which are defined in the SQLite namespace:
- Open up Models/TodoItem.
- Add a using SQLite statement at the start of the file right below the existing using statements, as in the following code:
using System;
using SQLite;
- Add the PrimaryKey and AutoIncrement attributes right before the Id property, as in the following code:
[PrimaryKey, AutoIncrement]
public int Id { get; set; }
The PrimaryKey attribute instructs SQLite that the Id property is the primary key of the table. The AutoIncrement attribute makes sure that the value of Id is increased by 1 for each new TodoItem class that is added to the table.