Development

Entity Framework Core Command Line Reference

Installing Entity command line The .NET Entity Framework command line tools can be installed globally in PowerShell, or just for a specific project. dotnet tool install --global dotnet-ef After installation, it might be a good idea to update the tools: dotnet tool update --global dotnet-ef Add the Entity Framework Packages to a Project In order to use the Entity Framework command line tools for a .NET Core project, it’s necessary to install the Design package.

.NET Core 6 - Dependency Injection, Repository Pattern and Unit of Work

A repository pattern exists to add another layer of abstraction between the application logic and the data layer, using dependency injection to decouple the two. It’s not my preferred way of doing things, because of the effort and complexity involved, and I’m certainly not the only person who initially struggled to understand the concepts behind it. Plus, it’s apparent that Entity Framework makes heavy use of that dependency injection already. But a Repository Pattern is widely considered - by software engineers far more experienced than I am - best practice for engineering services that deal with critical data.

Implementing an AJAX Request in .NET Core 6 MVC

One of the problems with implementing a search feature that returns a table in a partial view is the Entity Framework model declarations must be strongly-typed. This means we run into difficulties declarating a model in the containing view and an IEnumerable instance of it for the partial view. One way around this is to instead discard the model for the mainview, and use jQuery and AJAX to read values from specific input elements in the main view, and pass those values to the controller action that returns the partial view with the IEnumerable model.

Several potential fixes for the missing .NET SDK error (Docker and .NET Core)

There have been many people asking about this on Stack Overflow, and none of the answers there brought me closer to resolving the problem, which, it later transpired, was caused by something really silly I’d overlooked. When running ‘docker-compose up’ in the Docker CLI, for a .NET Core service, the output reports that it cannot find an installed SDK: It was not possible to find any installed .NET Core SDKs Did you mean to run .

Thoughts on NET Core 6.0, Entity Framework and the New MVC Pattern

The following mostly doesn’t refer to problems native to the .NET Core 6 Framework itself, but rather some difficulties I encountered while getting an Entity Framework Database-First model working in the MVC project template generated by Visual Studio 2022. Some of the problems centred around: Breaking changes and things that might be awkward for developers accustomed to working with legacy non-Core versions of .NET (espectially .NET MVC). Not much documentation out there, relative to what’s published for the older .

Using MKDocs

As you can tell, this site is no longer based on Publii CMS (which is still a very good CMS). After spending a few hours with MkDocs, I’ve been tempted to use that instead, as I can do pretty much everything using Vim. I’m still migrating the content, so this site is a work in progress. Using a static site generator might initially seem like a long-assed way of getting a basic site up, but once MkDocs is installed and running, and the site’s customised, we only need to worry about a single configuration file and where to place the content.

Things to do with .ipynb files

Although Jupyter Notebook is designed primarily for data analysts, I think there are other use cases in which it can be an effective method of distributing Python code and associated documentation in a single .ipynb file. There are other editors we can use to handle .ipynb files: JupyterLab, Deepnote and Visual Studio Code (with the right extensions) are just a few I’ve tried. Jupyter Notebook is essentially a markdown editor with an embedded Python interpreter that executes whatever code is included in a document.

Research Code Doesn't Need to Be a Tangled Mess

Writing at The Shape of Code blog, Derek Jones asserted that ‘Structural differences between academia and industry make it likely that research software will always be a tangled mess, only usable by the person who wrote it.’ Yes, there are structural (and insurmountable) differences between academia and industry in how programming languages are used to solve problems. Professional developers more often engineer code, because there are typically real-world consequences to releasing poor-quality software, from damage to a company’s reputation to injury or death.

OpenCart Development Notes

Overview The OpenCart system follows the MVC (Model, View, Controller) pattern. A simple description of how this works is that a View determines the layout and appearance of a Web site, whereas the content itself is generated and inserted into the View by a Controller. A Model contains data objects that represent database entities being processed by the Controller. With OpenCart, we have a more complicated implementation of the MVC pattern, mainly because a site’s appearance isn’t actually determined by a set of HTML/CSHTML files in the /views directory.