Configure Project References to Enable SQLite
To use Crosslight SQLite in your project, you need to configure the required references. To do this, simply use the NuGet extension for Mac or Visual Studio and install the Intersoft.Crosslight.Data.Sqlite package.
To learn more on how to use Crosslight NuGet Packages, see Introduction to Crosslight NuGet Packages.
After following this steps, your project should look like this:
Configure Entity Model (EDMX)
The Entity Model (EDMX) is an XML file that represents the list of entities and the relationship of every entity. To learn how to generate an entity model from a database, please refer to Creating Entity Model and Services with Crosslight Entity Designer Extensions.
Follow the steps below to configure the entity model:
- Open the EMDX file in the DomainModels project, right click at the empty space in diagram then select properties and change DevForceEnabled to false. This step is only needed if you have other third party entity tools installed such as DevForce.
- Select all your entities in the diagram, right click then select properties and change RepositoryType to EditableLocalEntityRepository.
By simply changing the repository type, the app will now store and load the data from local storage using SQLite.
Configure AppService.cs
Some configuration needed in AppSercive.cs are:
Define LocalDatabaseName and LocalDatabaseLocation in AppSettings.
AppService.cs - ConstructorAdd SQLite service to ServiceProvider.
AppService.cs - ConstructorCreate the tables for the models, and insert some predefined data.
Appservice.cs - Onstart Method
Disable Login and Synchronization (Optional)
Since the sample demonstrates how to use create an apps that use Local Storage, the app will not use synchronization, and most likely doesn't need login process. To skip the login process created by Crosslight Business Template, you can set the default RootViewModel to DrawerViewModel. To do this, simply change this.SetRootViewModel<HomeViewModel>() to this.SetRootViewModel<DrawerViewModel>() even if this.AccountService.IsLoggedIn() return false in AppService.OnStart method.
In addition, if the account and synchronization services aren't required, you can comment all the lines in the Navigated method of DrawerViewModel class, except base.Navigated(parameter).
Samples