Starcounter
HomeDownloadDocsCommunity
2.3.1
2.3.1
  • Starcounter Documentation
  • Getting Started
  • Starcounter
    • Collapsing the Stack
      • Complexity and Scalability Tradeoff
      • The Future of Micro-Services
      • 10 Benefits of Collapsing the Stack
    • Integrated Database and Web Server
  • Hello World - Tutorial
    • Create a Database Class
    • Create a Real Time UI
    • First Interactive UI
    • Computed Properties
    • Expense Tracker
    • Cancel and Delete
    • The Next Step
  • Guides
    • Database
      • Database Classes
      • Data manipulation
      • Object Identity and Object References
      • Querying with SQL
      • Data Types
      • Relations
      • Inheritance
      • Sharing data
      • Database Configuration
      • Comparing Database Objects
      • Referential Integrity and Constraints
    • SQL
      • Identifiers
      • Path Expressions
      • Data operators
      • Joins
      • Aggregates
      • Comparisons and Logical Operators
      • Sorting
      • Fetch
      • Offset Key
      • Indexes
      • Literals
      • Query Plan Hints
      • Reserved words
      • Query for Database Classes
      • SQL Isolation Between Applications
    • Transactions
      • Short-Running Transactions
      • Long running transactions
      • Using Transactions
      • Running Background Jobs
      • Commit Hooks
    • Typed JSON
      • JSON-by-example
      • Code-Behind
      • Data Bindings
      • Callback Methods
      • Responding with JSON
      • Accepting JSON in Requests
      • Primitive Arrays and Single Value Types
      • Typed JSON Internals
    • Blendable Web Apps
      • Starcounter MVVM
      • Palindrom
      • Client-Side Stack
      • Sessions
      • HTML Views
      • App Shell
      • Web Components
      • View Attaching
      • View Composing
      • HTML Compositions
      • HTML Views Blending Guidelines
      • Avoiding CSS conflicts
      • Debugging
    • Network
      • HTTP
      • Internal Self Calls
      • Middleware
      • Anonymous or Substitute Handlers
      • URL Aliases and Redirects
      • Network Gateway
      • Static File Server
      • External HTTP Calls
      • WebSocket
      • Avoiding URI conflicts
      • TCP Sockets
      • UDP Sockets
    • Publishing Apps
    • Working with Starcounter
      • Release Channels
      • Starting and Stopping Apps
      • Administrator Web UI
      • Star CLI
      • StarAdmin CLI
      • StarDump CLI
      • Working in Visual Studio
      • Error Log
      • Using HTTPS on NGINX
      • Using HTTPS on IIS
      • Run Starcounter in Production
      • Weaver
      • Investigating App Crashes
      • Configuration Structure
      • Database Refactoring
      • Using Unload/Reload to Modify Database Schema
      • Kernel Questions and Answers
      • Log Files
  • Cookbook
    • Attach an HTTP Request to an Existing Long-Running Transaction
    • Cookie-Based Authentication
    • Timestamp on Object Creation
    • Creating Strongly Typed JSON Collections
    • Migrating From 2.2 to 2.3+
    • Multiple Pages
    • Icons
    • Proposed Project Structure
    • Acceptance Testing with Selenium
    • Requesting a User to Authenticate
    • How to delete unused tables and columns
Powered by GitBook
On this page
  • Introduction
  • Creating a common data model
  • Add to apps
  • The Simplified data model
  • Packing apps with common data models
  1. Guides
  2. Database

Sharing data

PreviousInheritanceNextDatabase Configuration

Last updated 7 years ago

Introduction

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.

Creating a common data model

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.

Add to apps

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.

Don't extend the common data model or create database classes that reference the common data model in apps. Starcounter will then fail to read the data if one of the apps are not running.

When you run multiple apps with a common data model, restarting one app will not reload the common data model DLL. Thus, any changes in the common data model requires the database to be restarted.

The Simplified data model

All the Starcounter 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.

Packing apps with common data models

To create packages with starpack, the DLL must be in the package together together with the app executables.

sample apps