Stumbled across my MS thesis about the importance of processes in Software Development

Just stumbled across my 2004 MS thesis – “A Case Study into the Effects of Software – Process Improvement on Product Quality” – as study into the effects of agile project process maturity on the types of defects that surface in a software product. Still interesting stuff (at least some of the principles discovered) almost 20 years later 🙂 #scary

Has anything changed? 🙂

Blazor: Modifying header meta and link elements

When creating web applications, we all try to create good SEO tags in the header of each page. Modifying the meta tags based on page content is a standard practice. In Blazor, this is not obvious as the _host.cshtml is rendered before the Blazor execution pipeline.

There was a tag extension in the preview of Blazor 5 which didn’t make it into the release and there are no news if this is continued or not (just a note from a program manager that this didn’t make it into the release) … so I guess this will be solved across the board in next release …. ? 🙂

Fortunately we have Toolbelt.Blazor.HeadElement (https://github.com/jsakamoto/Toolbelt.Blazor.HeadElement/)

This works nicely if you make sure to use server prerendering as explained in the documentation. The default setup options result in (at least) the Facebook screen scraping does not collect the updated title and meta elements, but only the original ones (which are the site static default ones).

This is all fixed with ….

 app.UseHeadElementServerPrerendering();

…. as described in the documentation. Check out: https://golf80.com/Rounds/33957

EF6 core – reset migrations during development

In development and while testing various things in EF6 core – I tend to end up with a lot of migration garbage which occasionally I have to take out. This is how it’s done #notetoself

  1. Delete all *. cs files in the Migrations Folder.
  2. Delete the _MigrationHistory Table in the Database
  3. Delete all database tables subject to the migration (take care of the data 🙂 ).
  4. Run dotnet ef migrations add Reset
  5. Run dotnet ef migrations list to get the full name of last migration
  6. Run dotnet ef database update [migration-name]

#notetoself

EF6 core – load grandchildren in query – the key is ThenLoad

Working with entity: Tournament

Which has children: TRound with Course as entity that needs to be loaded based on Id ( as each golf round is played on a Course 🙂 )

ctx.Tournaments.Include(c => c.Trounds).ThenInclude(c => c.Course)

Took me a while to figure out why ctx.Tournaments.Include(c => c.Trounds.Select(c => c.Course)) stopped working, but it is a (good) core thingy.

Blazor OnClick doesn’t fire

#notetoself … Once again, scratching my head for way to long about something that turns out to have a simple workaround #devlife

On one of my (new) blazor pages (/Bookings/TeeTimes), onclick event was not firing. Didn’t matter what kind of flavour of onclick declaration I used, the event was not getting fired.

Until of course I noticed that this page was producing a lot of blazor loading errors:

Turns out I was running the project (as usual) from command line (dotnet) and had a shortcut in my browser to go directly to this page. Seems like that sets the “document root” to “Bookings” and from that it tries to find the blazor files.

Starting from the root page and navigating to the Bookings/TeeTimes page solved the problem, with the permanent fix being adding this within the head element of the layout

<base href="/" />

Docker networking #notetoself

Networking

  • List network setup: docker network ls
  • List: docker network inspect -f '{{range .IPAM.Config}}{{.Subnet}}{{end}}' [networkid]
  • List IPs of all containers.  docker network inspect -f '{{json .Containers}}' [networkid] | jq '.[] | .Name + ":" + .IPv4Address'
  • View host setup: docker exec [nameofnode] cat /etc/hosts
  • Running a named container: docker run -name api1 -p 8080:80 gcp-api

Installing ping in the container: https://stackoverflow.com/questions/39901311/docker-ubuntu-bash-ping-command-not-found
Setting up a network:
https://www.digitalocean.com/community/questions/how-to-ping-docker-container-from-another-container-by-name

Docker networking for Dummies (like me) https://www.freecodecamp.org/news/how-to-get-a-docker-container-ip-address-explained-with-examples/

Classic Setup (web, api, sql)

Setting up the classical environment of having the following 3 components, Web, API, SQL

A few extra notes

A note to self. Use remote command bash when the docker attach command hangs: docker exec -it [container-id] bash

Migrating from DB first EF6 to EF core

Continuing my framework move from .net framework 4.8 to .net 5 (Preview7) I obviously have to take the step moving from a framework Entity Framework to EntityFrameworkCore. A few notes to self regarding the upgrade.

The old context generation doesn’t make sense any more. EF core understandably doesn’t have the design options 4.8 (EF 6.2) had, so what made sense for me was to regenerate the model from database using

Scaffold-DbContext (See e.g. https://www.entityframeworktutorial.net/efcore/create-model-for-existing-database-in-ef-core.aspx)

This simply worked out of the box, with a new code representation of my database generated in the defined target folder.

As I am dealing with substantial number of tables, some with non-orthodox naming conventions (plural entity names – which I will fix), the generated code varied slightly from my pre-existing entity structure, breaking a lot of code.

Also, the stored procedures were missing. They are now executed using .FromSql or .ExecuteSql (See e.g. https://www.entityframeworktutorial.net/efcore/working-with-stored-procedure-in-ef-core.aspx)

A bit of “back to the future” effect on this one 🙂

Next creating a baseline database migration from my old database was easy. Just followed these guidelines: https://cmatskas.com/ef-core-migrations-with-existing-database-schema-and-data/ …. and voilá!! the first migration was added to my database.

Now it is just a matter of cleaning up a bit in the database, creating a clear migration path from the production database to the target setup for GolfCloudPro.com …. easy right!? :Þ