Introduction
Starcounter 3.0.0 Alpha 20190701, codenamed Nova, is available for public preview.

Starcounter 3.0 main focus

  • Support Linux & Windows operating systems.
  • Provide seamless integration with standard .NET Core applications:
    • .NET Core Console applications.
    • .NET Core Web applications with Kestrel web server.
    • .NET Core Desktop applications.
  • Support development experience with standard dotnet CLI tooling.

Requirements

Note: Due to the preview state of this release we cannot provide any guarantees, but we monitor our GitHub: Starcounter/Home issue tracker and stand ready to assist with any potential issues.

Installation

Note: This section assumes that you have required operating system and .NET Core 3.0.100-preview6-012264 SDK installed.

Binaries

  • Create a folder for Starcounter binaries, for example Starcounter.3.0.0-alpha-20190701.
  • Download Starcounter.3.0.0-alpha-20190701.zip into the folder.
  • Unzip downloaded archive into the folder.

Ubuntu 18.04

Install prerequisites.
1
sudo apt-get install wget unzip
2
sudo apt-get install libaio1
Copied!
Starcounter relies on a specific version of SWI-Prolog.
1
sudo add-apt-repository ppa:swi-prolog/stable
2
sudo apt-get update
3
sudo apt-get install swi-prolog-nox=7.\*
Copied!
Download and unpack Starcounter binaries.
1
cd $HOME
2
mkdir Starcounter.3.0.0-alpha-20190701
3
cd Starcounter.3.0.0-alpha-20190701
4
wget https://starcounter.io/Starcounter/Starcounter.3.0.0-alpha-20190701.zip
5
unzip Starcounter.3.0.0-alpha-20190701.zip
Copied!

Application

Create an application folder and initialize a .NET Core console application.
1
mkdir StarcounterConsoleSample
2
cd StarcounterConsoleSample
3
4
dotnet new console
Copied!
All the following commands shall be executed from the StarcounterConsoleSample folder.
Setup NuGet to consume Starcounter packages feeds.
Create nuget.config file and add required package sources:
  • local, points to the Starcounter binaries folder.
  • Starcounter, points to https://www.myget.org/F/starcounter/api/v2.
NuGet tips:
  • Default NuGet.config file can be created with dotnet new nugetconfig command.
  • For more information on how to work with NuGet configurations, see this post by Microsoft.
End file should look similar to this:
1
<?xml version="1.0" encoding="utf-8"?>
2
<configuration>
3
<packageSources>
4
<clear />
5
<add key="local" value="[Starcounter.3.0.0-alpha-20190701]" />
6
<add key="Starcounter" value="https://www.myget.org/F/starcounter/api/v2" />
7
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
8
</packageSources>
9
</configuration>
Copied!
Visual Studio Setup:
Visual Studio requires manual NuGet package sources configuration. For this go to the Tools → Options → NuGet Package Manager → Package Sources menu then add local and Starcounter feeds.
Note: Replace the [Starcounter.3.0.0-alpha-20190701] value with actual path to the folder with unzipped Starcounter binaries.
Add Starcounter.Nova.App package reference
1
dotnet add package Starcounter.Nova.App --version 3.0.0-*
Copied!
Add minimal Starcounter database access
Replace content of the Program.cs file with the following:
1
using System;
2
using System.Linq;
3
using Starcounter.Nova;
4
using Starcounter.Nova.Hosting;
5
6
namespace StarcounterConsoleSample
7
{
8
[Database]
9
public abstract class Person
10
{
11
public abstract string Name { get; set; }
12
}
13
14
class Program
15
{
16
static void Main(string[] args)
17
{
18
using (var host = new AppHostBuilder().Build())
19
{
20
host.Start();
21
22
string name = Db.Transact<string>(() =>
23
{
24
var p = Db.SQL<Person>
25
(
26
"SELECT p FROM StarcounterConsoleSample.Person p WHERE Name = ?",
27
"Jane"
28
).FirstOrDefault();
29
30
if (p == null)
31
{
32
p = Db.Insert<Person>();
33
p.Name = "Jane";
34
}
35
36
return p.Name;
37
});
38
39
Console.WriteLine(name);
40
}
41
}
42
}
43
}
Copied!
For ASP.NET Core application:
Update Startup.cs class with the following:
1
using Starcounter.Nova.Hosting;
2
using Starcounter.Nova.Extensions.DependencyInjection;
3
4
namespace StarcounterMvcSample
5
{
6
public class Startup
7
{
8
/* Some other code here. */
9
10
public void ConfigureServices(IServiceCollection services)
11
{
12
/* Some other service declarations here. */
13
14
services.AddStarcounter(new AppHostBuilder());
15
}
16
17
/* Some other code here. */
18
}
19
}
Copied!
Note: Starcounter works with Kestrel Web Server only. IIS and IIS Express are not yet supported.
Install Starcounter dotnet CLI tool and create database
1
dotnet new tool-manifest
2
dotnet tool install Starcounter.Star.Tool --version 3.0.0-*
3
4
dotnet star new
Copied!
Now there will be a Starcounter database located in the StarcounterConsoleSample/.stardata folder.
Start database and application
Start the database.
1
dotnet star start
Copied!
Run the application.
1
dotnet run
Copied!

Running with Visual Studio Code

  • Open Visual Studio Code in the application folder (from command line: code ./).
  • Restore dependencies Visual Studio Code asks for.
  • Click Ctrl + F5 to start the application.
Everything should run out of the box.

Running with Visual Studio 2019

  • Update Visual Studio 2019 to the latest version using Visual Studio Installer.
  • We checked version 16.1.5 (as of July 3 2019).
  • Open Tools → Options and enter "preview" in the search box.
  • In Environment → Preview Features check Use previews of the .NET Core SDK and restart Visual Studio.
  • Open StarcounterConsoleSample.csproj from Visual Studio.
  • Set the debug path in Project properties → Debug → Working directory to the path of the project. E.g. C:\StarcounterSamples\StarcounterConsoleSample.
  • Click Ctrl + F5 to start the application.
It is also possible to set working directory in the .csproj file by adding the following:
1
<PropertyGroup>
2
<RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory>
3
</PropertyGroup>
Copied!

Extra information

Before asking questions or reporting issues, please read these few lines, and maybe you will find an answer for your question.
  • Currently there is no database tooling available except the bare minimum of dotnet star new and dotnet star start commands.
  • Currently it is only possible to start the database manually.
  • Currently it is only possible to store the database files in the default .stardata folder.
  • Currently it is not supported to have a dot (.) in the application name. For example app may use CompanyApplication as it's name, but Company.Application is not supported.
  • Starting from Starcounter 3.0.0 beta, all required packages will be uploaded to one of the popular providers, such as NuGet.org, MyGet.org or GitHub Package Registry.
  • Base namespace will be changed from Starcounter.Nova to just Starcounter.
  • It is recommended to define all database classes and properties as abstract to reduce memory footprint when compared to virtual. Support for virtual properties might be removed in the future.
  • Packing with dotnet pack and publishing with dotnet publish are not yet implemented for applications which use Starcounter database.
Last modified 2yr ago