# Scaffolding an existing SQL database with Entity Framework Core in 5 minutes

Sometimes it’s nice to get a break from ‘legacy’ software. In this case we would like to get started using Identity Server 4 with an existing database running on SQL. Wouldn’t it be nice to get up and running in a few minutes? Hold on.

We’re using the dotnet cli for speed, and cross platform usefulness (OS X, Windows(?) and Linux). We assume you’ve booted your favorite terminal and you are in your solution folder. Buckle up buddy!

mkdir <YOUR_PROJECT_FOLDER>
cd <YOUR_PROJECT_FOLDER>
dotnet new classlib



After these packages have been installed we need to add the following two lines to the .csproj file in the current folder. These are required in order to use the Entity Framework tooling from the command line. Use your favorite text editor:

<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
</ItemGroup>


Ps. make sure these 4 lines are somewhere within the <Project> tags, or grouped with other <DotNetCliToolReference> tags eventually already in your file.

In order to be able to run migrations from this project we will configure it to be able to act as being startup project. There should be a line which is:

<TargetFramework>netstandard2.0</TargetFramework>


Change it to:

<TargetFrameworks>netcoreapp2.0;netstandard2.0</TargetFrameworks>


Just copy paste it for your speed, and sanity. Now you’re ready to scaffold your data model from the database. In order to do so:

dotnet ef dbcontext scaffold "<CONNECTION STRING>" Microsoft.EntityFrameworkCore.SqlServer


In case you get an error about the framework versions you need to install, just determine the current version by running the dotnet --info command and grabbing the value from under the Microsoft .NET Core Shared Framework Host line. Next add the following tag just under the <TargetFramework> tag and you’re good to go.

<RuntimeFrameworkVersion>2.0.5</RuntimeFrameworkVersion>


Congratulations! You should now have your existing data model ready to use within your .NET Core application using Entity Framework Core :)

# Visualizing airspace usage by glider aircraft

In the past year I have done a significant amount of work to process flight information from glider aircraft. For reference, in 2017 I have processed about 1,000,000,000 position updates and at the end of the year I had a database which stored about 700,000,000 data points, which represented over 30,000 unique aircraft. One data point contains information like latitude, longitude, altitude, speed, heading, climb-rate and turn-rate.

Funny thing; the difference between the amount of processed points and stored points came from beginning of the year, when I accidentally deleted the database, containing 300,000,000 data points, during a migration. Oooops. Should’ve made proper back-ups!

A while ago I decided to export just a little bit of data to look into in detail. The data export contained all data from Sunday 13th of August, 2017, on which the 19th edition of the FAI European Gliding Championships has been held from Lasham Airfield.

To get an idea of the sheer size of the event, check out the video from the British Gliding Team above. In order to get an idea of the glider activity, on this day alone, check the image below.

Please note that on this day alone about 14,000,000 position update have been recorded. Considering an aircraft sends out an position update about once a second that means a little less then 4000 hours of flight activity has been recorded, on this day alone.

I managed to create a quick visualization of gliders coming back to Lasham airfield starting at around 15:30Z. See below!

The things I’m displaying here represent only a small portion of the work which has been done, and an even smaller portion of the full potential of this data in combination with the right tooling. Although this by far isn’t the end result I’m wanting to achieve I’m already quite proud on this humble result! More and better stuff will definitely follow in the future! Stay tuned for further updates! :)

# .NET core application not logging output to Docker

Since the introduction of .net core 2.0 everything on the .net platform seems to become better and better. Since the introduction of Visual Studio for mac it encouraged me to switch over to a mac OS X only dev environment.

Needless to say my current development environment with Visual Studio, Docker, and Kitematic works amazing. And I only just started figuring things out.

The thing which has been bugging me though was that it seemed like application output (stdout and stderr) was not being logged to Docker while it was being logged to Visual Studio.

## How to get an application to log to Docker

Docker containers built from microsoft/dotnet:2.0-runtime or microsoft/aspnetcore:2.0 have a /remote\_debugger volume which maps to ~/.vsdbg. For now I can only imagine how this stuff works, but I suppose that when the remote debugger is attached the application only logs to the remote debugger which may or may not be favorable behavior.

In case you know more about the /remote\_debugger volume and the ~/.vsdbg thingy or you can point me in the right direction, I’d love to hear more from you! Hit me up on Twitter!

# XKCD 1110 Homage

Shame on you if you don’t know about XKCD or don’t know about the great comic number 1110. Randall Munroe has gone above and beyond to deliver a 10 gigapixel map you can drag yourself through. Wait, don’t explore yet! The best is yet to come.

In response Kajaklubben has created an interactive version of this map where you are actually part of the comic itself and can explore the whole world by walking through it, flying with your lill’ balloon or falling off cliffs and in tunnels.

But as with most things on the internet, this amazing homage went offline, but the source was still available at GitHub and so I forked it! Thanks to GitHub pages you can now enjoy this amazing work of art again.