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

SqlException: Invalid column name GolferId

EF6 Core – reconfiguring navigation properties, the runtime was complaining about a column GolferId being missing (invalid database column).

Took me a minute to figure out and remember the default foreign key dependency naming convention in EF. Sometimes these frameworks are a bit too intelligent for my taste.

Turns out the EF was guessing that if I have a navigation property to a related entity called “User” – the framework will automatically use an object property field called “UserId” :/ … easily solved with the ForeignKey tag 🙂

https://stackoverflow.com/questions/46091157/changing-default-column-name-for-navigation-property

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!? :Þ

Xamarin.Forms Messaging center failing silently

I had a problem with Xamarin.Forms MessagingCenter – as sometimes the messages disappeared. Code that on most occasions worked nicely failed silently and from debug output – the messages never reached the subscription methods. What I eventually found out was happening (after days of frustration) was that one of the subscriptions was updating the UI and since this is on a thread other than the main one – it just failed silently and the next message subscription never got the message. This is not a 100% diagnostic (I don’t care to waste more time on this) but moving the UI updates explicitly to the main thread solved the issue. Hope this helps someone … a day or two of pointless debugging 🙂

APK signertool issue -Java Runtime only recognizes class file versions of up to 52.0

NOTE TO SELF:

Signing packages failed. java.lang.UnsupportedClassVersionError: com/android/apksigner/ApkSignerTool has been compiled by a more recent version of Java Runtime(class file version 53.0), this version of the Java Runtime only recognizes class file versions of up to 52.0

https://stackoverflow.com/questions/60441090/apksignertool-issue-with-java-version

Confirmed Solution: . I solved it removing version 30.0.0 (rc2) of android build tools 

 

Að prófa Gigg.Live

Takk fyrir að skoða þennan póst – ætlaðan fyrir þá sem eru til í að hjálpa til við að prófa nýtt app sem ég (Geir) og Snillinn Jói (snilli.is) erum að setja í loftið.

Við erum að prófa BETA útgáfu af appinu – sem þýðir að það þarf eitt auka skref til að prófa.  Öll endurgjöf er ofboðslega vel þegin á þessum tímapunkti – annað hvort með því að senda okkur Jóa bara skilaboð á Facebook eða  í gegnum Twitter eða Facebook reikning Gigg.Live

Hvernig setur þú upp appið? … stutta útgáfan (video neðst)

Hvernig setur þú upp appið? …ítarlega útgáfan

Skref 1

Smelltu á eftirfarandi tengil: https://play.google.com/apps/testing/org.centersoftware.gigg.xmobile/join?hl=is-IS

Þá kemur eftirfarandi mynd upp – sem segir að þú sért að taka þátt í prófunum og appið sé ekki endilega fullklárað og þú gætir lent í smávillum í símanum.   Þú smellir á smellir á “Become a tester”, það tekur nokkrar mínutúr að virka eftir að þú smellir á hnappinn. Þannig að þú færð þér bara kaffi á meðan 🙂

Screenshot 2020-04-20 at 13.21.27

Skref 2

Opnaðu vefsíðuna https://gigg.live í símanum.   Þar er merki sem segir  “Get it on Google Play”  Smelltu á þann takka til að setja Gigg.Live upp í tölvunni.

Screenshot 2020-04-20 at 13.34.50

Skref 3

Þegar þú ferð svo yfir í Play Store – þá er bara eitt mikilvægt 🙂 … það er að þú sjáir að undir “What’s new” þá standi “Last updated 20 Apr 2020” (ekki 14. eða 15 apríl … þá krassar appið bara hjá þér.

Screenshot_20200420-134747_Google Play Store

Hvernig setur þú upp appið? … videoið