Starcounter apps in the same code host share the same database. This means that if one app changes some data in the database, all other apps in the same code host will immediately see that change. This, together with Blending, makes it possible for two apps that have been developed separately to act as one.
To share data between the apps, they have to agree on a common database schema for the tables that they wish to share. This is done by defining a common data model in a separate assembly.
One of the templates provided with the Visual Studio extension can be used to create a starting point for a common data model. The template is called "Starcounter Class Library" and can be found under
Add New Project -> Visual C# -> Starcounter -> Starcounter Class Library.
The database classes that will be shared across different apps can be added to this project.
To conveniently share the common data model, it can be put in the same Visual Studio solution as the apps or uploaded to NuGet.
To include this common data model in an application, add it as a reference. For it to properly work, the "Copy Local" property has to be set to false. This can be done in the "Properties" tab of the reference. This means that the common data model will be shared as a dynamic-link library (DLL) between the apps.
When sharing a common data model across apps, the apps have to reference the same version of the DLL.
All the Starcounter sample apps use a preinstalled data model called "Simplified". This allows all these apps to share data. To utilize this data model and share data with the sample apps, load the data model into an app by referencing it and setting "Copy Local" to false.
To create packages with
starpack, the DLL must be in the package together together with the app executables.