Windows Core IoT – SQLite on a Raspberry PI3

As shown in the previous post you can run use Dotnet Core to compile apps for Windows IoT on a RPI3

See here how to get started with Dotnet Core

On the net you can find how to use Dotnet Core and SQLite :

https://developersoapbox.com/connecting-to-a-sqlite-database-using-net-core/

But the example uses the Dotnet Core v1.0 Framework and run on Windows.

I will show here how to use the latest Dotnet Core v2.0 Framework and publish it for Windows ARM on RPI3 Winking smile

Run command Dotnet new console –n Sqlite –o C:\DotNetCoreApps\Sqlite

And check the result here :

image

Copy the program.cs as backup, and copy the program code from the site above into the program.cs file.

Change the namespace to SQLite (see-n SQLite in first command)

clip_image002

Change the sqlite.csproj file content by adding a few lines

clip_image002

Add these line :

image

<Project Sdk=”Microsoft.NET.Sdk”>

  <PropertyGroup>
     <OutputType>Exe</OutputType>
     <TargetFramework>netcoreapp2.0</TargetFramework>
     <RuntimeIdentifiers>win8-arm;ubuntu.14.04-arm;ubuntu.16.04-arm</RuntimeIdentifiers>
   </PropertyGroup>
   <ItemGroup>
<PackageReference Include=”Microsoft.EntityFrameworkCore.Sqlite” Version=”2.0.2″ />
<PackageReference Include=”SQLitePCLRaw.bundle_green” Version=”1.1.10″ />

  </ItemGroup>
   <ItemGroup>
     <DotNetCliToolReference Include=”Microsoft.EntityFrameworkCore.Tools.DotNet” Version=”2.0.0″ />
   </ItemGroup>
</Project>

Run command : dotnet Restore

image

As you can see it will use some Nuget packages as included in the sqlite.csproj file

Next run this command : dotnet publish -r win8-arm

And copy the files to your RPI3

image

Next open PowerShell do a remote session and run the .\SQLite.exe

image

When the SQLite DB doesn’t exist yet, it will be created automatically.

image

DotNet Core is really a cross-platform language !

It runs flawlessly on a RPI3 – ARM Architecture, by just re-using the same code base we use on a Windows machine Smile

See here for more info on .NET Core Data Access data sources :

https://blogs.msdn.microsoft.com/dotnet/2016/11/09/net-core-data-access/

Enjoy !

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: