Modeling your database with types and attributes
OrmLite provides several attributes that you can use to annotate your data types—several of these allow you to control the underlying table schema. For instance, you can assert that a specific field be indexed to auto-increment integers and assign primary and foreign key relationships. In this recipe, we'll show you how.
Getting ready
In this recipe, we'll start with a basic data model using SQLite and OrmLite. We'll build up our types and view the schema that OrmLite creates. Then, we'll apply various attributes and see how the schema changes. To get started, you'll need a new project created either using a template from the ServiceStackVS extension or by following the section Creating a ServiceStack solution with Visual Studio and NuGet in Appendix A, Getting Started.
How to do it…
Install the
Sqlite.OrmLite
NuGet package to your application. This will be needed whenever you registerIDbConnectionFactory
withServiceStackHost
, usually yourAppHost...