Simple and Effective tool for .NET developers

Raw Coding
26 Jun 202407:25

Summary

TLDRIn this video, the host introduces 'make', a tool that simplifies repetitive tasks, particularly useful for .NET developers. Despite not being a Microsoft or C# tool, 'make' offers simplicity and utility. The tutorial demonstrates creating a .NET 8 application with Entity Framework Core and PostgreSQL, illustrating the process of generating migrations. The host then shows how to automate these commands using a 'makefile', enhancing consistency and reusability across different environments, including local development and CI/CD pipelines. The video concludes with instructions on installing 'make' and utilizing variables for more dynamic command execution.

Takeaways

  • πŸ› οΈ The video introduces 'make', a tool that simplifies command execution and is useful beyond just .NET developers.
  • πŸ’‘ Despite not being part of the Microsoft ecosystem, 'make' is highlighted for its utility and ease of use.
  • πŸ“ The presenter demonstrates how to use 'make' for generating Entity Framework Core migrations in a .NET application.
  • πŸ”„ The video addresses a common issue with command recall and consistency, especially in different environments like local and CI/CD pipelines.
  • πŸ“ The presenter creates a 'makefile' to store and reuse the command for generating migrations, avoiding repetitive typing.
  • πŸ–₯️ The video shows how to install 'make' on different operating systems, with a focus on Windows using Chocolatey.
  • πŸ”§ The script explains how to define and use variables in 'make' to make commands more dynamic and adaptable.
  • πŸ”„ The presenter emphasizes the benefits of using 'make' for reusable scripts that can be shared across teams and computers.
  • πŸ”§ The video provides a practical example of how to pass parameters to 'make' commands to further customize command execution.
  • 🌐 The script concludes by encouraging viewers to adopt 'make' for better command management and consistency in development workflows.

Q & A

  • What is the main tool discussed in the video?

    -The main tool discussed in the video is 'make', which is a tool that can be used to automate tasks and is not limited to .NET developers.

  • Why might .NET developers be initially hesitant to use 'make'?

    -.NET developers might be hesitant to use 'make' because it is not part of the Microsoft ecosystem and is not a C# (sharp) tool, which could lead to a reluctance to use non-Microsoft or non-C# tools.

  • What problem does the 'make' tool help solve in the context of the video?

    -The 'make' tool helps solve the problem of generating database migrations in a consistent and reusable way, which can be challenging and prone to errors when done manually.

  • How does the video demonstrate the use of 'make' for generating migrations?

    -The video demonstrates the use of 'make' by showing how to create a 'makefile' with a command to generate migrations, which can then be executed with a simple 'make' command from the command line.

  • What is the significance of using a 'makefile' in the video?

    -A 'makefile' is significant because it allows for the creation of reusable scripts that can be executed with 'make', making it easier to automate and document commands for various tasks, such as generating migrations.

  • How does the video suggest passing parameters to 'make' commands?

    -The video suggests passing parameters to 'make' commands by defining variables in the command line and then using those variables within the 'makefile' to customize the commands being executed.

  • What is the benefit of using 'make' in both local development and CI/CD pipelines?

    -Using 'make' in both local development and CI/CD pipelines ensures consistency in how commands are executed, making it easier to maintain and share scripts across teams and environments.

  • How can 'make' be installed on different operating systems as mentioned in the video?

    -On macOS or Linux, 'make' may already be installed, and on Windows, it can be installed using Chocolatey, which is suggested as the simplest approach in the video.

  • Why might JetBrains Rider prompt for a plugin when a 'makefile' is opened?

    -JetBrains Rider might prompt for a plugin when a 'makefile' is opened because it recognizes the file type and suggests a plugin to provide syntax highlighting and better support for editing 'makefiles'.

  • What is the purpose of using tabs instead of spaces in 'makefiles' as highlighted in the video?

    -In 'makefiles', tabs are used instead of spaces for indentation because 'make' is sensitive to the indentation method, and using tabs is a common requirement to avoid issues with the execution of the commands.

  • How does the video encourage viewers to engage with the content?

    -The video encourages viewers to engage by asking them to leave comments if they have used 'make' or similar tools, and to ask questions in the comment section if they have any, fostering a community of learners and users.

Outlines

00:00

πŸ› οΈ Introduction to the 'make' Tool for .NET Developers

The speaker begins by welcoming the audience and introducing a tool called 'make', which they have found useful despite not being part of the Microsoft ecosystem. They emphasize that the tool is not exclusive to .NET developers but can be beneficial to anyone. The speaker acknowledges a common bias among .NET developers against non-Microsoft tools but encourages them to consider 'make' due to its simplicity and utility. The video is aimed at .NET developers, and the speaker invites viewers to continue watching to learn more or to leave comments if they have questions. They also remind viewers to like, subscribe, and check the description for more information. The speaker then demonstrates a simple .NET 8 application with Entity Framework Core using PostgreSQL. They show the process of registering the database context and the model in the application. The main issue discussed is the challenge of generating migrations using the 'dotnet ef migrations add' command, which often requires specifying the startup project and the project containing the database context. The speaker suggests that 'make' can help simplify this process by creating a reusable command.

05:00

πŸ“ Using 'make' to Simplify Command Line Operations

The speaker demonstrates how to use the 'make' tool to create a reusable script for generating database migrations. They create a 'Makefile' and paste the necessary command into it, commenting out the command with a hashtag. They mention that JetBrains Rider, their IDE, does not initially support Makefiles but offers a plugin for syntax highlighting. The speaker explains how 'make' works by defining a command 'test' that simply echoes 'hello'. They show how to run this command using 'make test' in the terminal. The speaker then moves on to discuss how to use variables with 'make', allowing for more dynamic and reusable scripts. They demonstrate passing a parameter to the 'make' command, using an emoji as an example. The video concludes with the speaker showing how to use 'make' to generate migrations with a specified name, creating a reusable script that can be used across different environments, including local development and CI/CD pipelines. The speaker encourages viewers to share their experiences with 'make' or similar tools in the comments and to support the video with a like and subscription if they found it helpful. They also mention the availability of the source code for patrons and thank the current patrons for their support.

Mindmap

Keywords

πŸ’‘make

Make is a build automation tool that is used to determine the order of execution of a set of programs and their dependencies. In the context of the video, the tool is introduced as a way to simplify and automate the process of generating database migrations in .NET applications. The video demonstrates how to use make to create a reusable script that can be executed from the command line, which is particularly useful for developers who need to manage complex build processes or repetitive tasks.

πŸ’‘.NET

.NET is a software framework developed by Microsoft that provides a large body of pre-coded solutions to common programming problems. It is used for building a variety of applications, including web, mobile, and desktop applications. In the video, the presenter mentions that although the tool 'make' is not part of the Microsoft ecosystem, it is still very useful for .NET developers, indicating that .NET developers often look for tools that are compatible with Microsoft's offerings.

πŸ’‘Entity Framework Core

Entity Framework Core is an open-source object-relational mapper (ORM) that enables .NET developers to work with a database using .NET objects. It eliminates the need for most of the data-access code that developers usually need to write. In the script, the presenter uses Entity Framework Core with a PostgreSQL database, which is an example of how developers can leverage ORMs to interact with databases in a more abstract and efficient way.

πŸ’‘database context

A database context in Entity Framework Core serves as a session with the database, allowing you to query and save instances of your entities. It is the starting point for all interactions with the database. In the video, the presenter mentions setting up a database context in a .NET application, which is a crucial step in configuring the application to interact with the database using Entity Framework Core.

πŸ’‘migrations

Migrations in the context of Entity Framework Core are a way to manage changes to the database schema over time for a .NET application. They allow developers to apply changes to the database structure in a controlled and versioned manner. The video discusses the process of generating migrations using the 'net ef migrations add' command, which is a common task when developing applications that require database schema changes.

πŸ’‘terminal

A terminal is a text-based interface for accessing a computer's operating system. In the video, the presenter uses the terminal to execute commands for generating database migrations and to demonstrate the use of the 'make' tool. The terminal is a common interface for developers to interact with their development environment and execute various commands.

πŸ’‘command line

The command line is a text-based interface for interacting with a computer's operating system. It allows users to execute commands and programs by typing them into the terminal. In the video, the presenter uses the command line to run the 'make' tool and to demonstrate how to generate database migrations, highlighting the utility of command-line tools in software development.

πŸ’‘syntax highlighting

Syntax highlighting is a feature of text editors and integrated development environments (IDEs) that displays text in different colors and fonts depending on the category of terms. This helps in identifying and distinguishing elements in a programming language. In the script, the presenter mentions that JetBrains, an IDE, offers syntax highlighting for 'makefile' after installing a plugin, which aids in writing and understanding 'makefile' scripts.

πŸ’‘variables

In the context of scripting and programming, a variable is a storage location paired with an associated symbolic name, which contains some known or unknown quantity of information referred to as a value. In the video, the presenter demonstrates how to use variables in 'makefile' scripts to pass parameters, such as the name of a migration, from the command line to the script, which is a common practice in automating tasks.

πŸ’‘GitHub workflow

A GitHub workflow is a configurable automated process that runs on GitHub-hosted runners and can be triggered by various events, such as pushing new code to a repository. In the video, the presenter suggests that 'make' commands can be used in GitHub workflows, indicating that the tool can be integrated into continuous integration and continuous deployment (CI/CD) pipelines to automate parts of the software development process.

Highlights

Introduction of a tool called 'make' that is useful beyond just .NET developers.

.NET developers' tendency to avoid non-Microsoft or non-C# tools.

Demonstration of a simple .NET 8 application with Entity Framework Core and PostgreSQL.

Explanation of how to register the database context in the app.

Challenges faced when generating migrations using the 'dotnet ef migrations add' command.

Solution to specify the startup project and database project for migration generation.

Introduction to the 'make' tool as a way to simplify and reuse command-line tasks.

Creation of a 'makefile' to store and run commands.

Use of tabs for indentation in 'makefile' to avoid common issues.

Installation of 'make' on different operating systems, including using chocolatey on Windows.

Utilization of variables in 'make' to make commands more flexible.

Example of passing parameters to 'make' commands to generate migrations.

Advantage of using 'make' for reusable scripts that can be shared across teams or computers.

How 'make' can be integrated into GitHub workflows for consistent command execution.

The simplicity of 'make' as a tool for creating reusable command-line recipes.

Invitation for viewers to share their experiences with 'make' or similar tools in the comments.

Call to action for viewers to support the creator on Patreon for continued video production.

Transcripts

play00:00

welcome back boys and girls in this

play00:01

video I'm going to be sharing a tool

play00:03

with you that I have personally found

play00:05

very useful the tool is called make and

play00:09

you don't have to be a net developer to

play00:11

find it very useful it's just my videos

play00:14

are for net that's why the video is

play00:16

titled like that but net developers have

play00:18

a special trait where if they see

play00:21

something that's not Microsoft or it's

play00:23

not C they're like I don't want to touch

play00:25

it this toll is not part of the

play00:27

Microsoft ecosystem it is not a sharp

play00:30

tool however it is a very useful tool

play00:33

and it's very simple to use so uh if you

play00:35

want to see what it's about continue

play00:38

watching otherwise don't forget if you

play00:39

have any questions make sure to leave

play00:41

them in the comment section don't forget

play00:42

to leave a like And subscribe don't

play00:44

forget to check out the description and

play00:45

let's go ahead and get started so very

play00:49

very simple application I have an app

play00:52

and I have a database so uh the app is a

play00:56

simple net 8 application we have a

play00:58

reference to the database project and I

play01:00

have Entity framework Core Design uh

play01:03

database as a postgressql Entity

play01:05

framework I have a model super simple

play01:09

and we have a database context where we

play01:12

have a DB set then in the program CS

play01:15

over here I am just reg registering the

play01:18

database context so on the surface super

play01:21

simple we Define a database we

play01:23

registered in the app now hopefully some

play01:27

of you have run into this problem we

play01:29

want to generate migrations so we would

play01:33

open up a terminal and let me make it

play01:36

maybe close the other one we will do net

play01:39

EF

play01:41

migrations add and then I don't know

play01:44

something like initialize uh at this

play01:47

point the tool will run and it will spit

play01:50

out some command you will add this

play01:51

command you will run it again and you'll

play01:53

be like it doesn't work so what do you

play01:56

do ultimately let's say after some

play01:59

Googling after finding other videos

play02:01

you're going to know that I need to

play02:05

specify which project is going to be the

play02:07

startup project which is going to be

play02:09

running the queries and uh such and then

play02:12

I want to specify which project is the

play02:15

project that contains the database the

play02:17

DB context where the migrations should

play02:19

be generated so uh let's do this we're

play02:22

going to do netf uh migrations ad and

play02:26

again I'm going to do in it but this

play02:28

time I'm going to be specifying a start

play02:30

project which is going to be the app. Cs

play02:33

project and then we're just going to be

play02:35

specifying the database project where

play02:37

the migrations should be generator right

play02:40

so database CS project and there we go

play02:43

now if I run this the migrations are

play02:46

going to be generated and there they are

play02:48

okay so I'm going to delete them

play02:51

hopefully a command like this some of

play02:54

you may be like I can remember it some

play02:57

of you will be like I can't remember it

play02:59

uh if you have have many different

play03:01

database projects which database are you

play03:03

using Etc are you going to get this

play03:05

command consistently between what you're

play03:07

typing locally and your cicd pipeline

play03:11

you effectively want to have this chunk

play03:14

to be reusable okay so we're literally

play03:17

going to take this chunk collapse the

play03:19

terminal and this is where the make tool

play03:22

comes in what I'm going to do is I'm

play03:23

going to switch to file system I'm going

play03:26

to add a new file and I'm just going to

play03:28

call it make file okay I will paste the

play03:31

command over here and I'm going to

play03:34

control forward slash so comment uh is a

play03:37

hashtag in this file okay and from the

play03:40

beginning jet brains doesn't have

play03:41

support for make file but then it says

play03:43

do you want a plugin because I

play03:45

understand what this F is and I was like

play03:46

yeah sure so now I have syntax

play03:48

highlighting here so uh how does make

play03:50

work uh let's say we are going to have a

play03:53

command called test and you can see

play03:54

writer is capable of running these

play03:56

commands uh do note this is a tab

play04:00

delimiter not space delimiter uh this is

play04:02

a common issue that can occur if you are

play04:04

basically putting spaces you have to

play04:06

indent with tabs but ultimately we will

play04:10

run a command like Echo and hello okay

play04:14

I'll save this file I'll open the

play04:16

terminal over here and I will make test

play04:20

okay and there we go and it just runs

play04:22

your command so super simple uh how you

play04:24

install make if you are on a MacBook

play04:27

like I am or a uh Linux machine it may

play04:31

already be installed if you're on

play04:32

Windows you can use chocolatey to

play04:34

install make I think that's that will be

play04:36

the simplest approach and yeah you

play04:39

basically just have the make Tool uh now

play04:42

another thing that you will probably

play04:45

want to learn is the thing that you're

play04:47

going to variate is this in it so you're

play04:50

going to want to effectively have this

play04:52

as a variable that you pass from the

play04:53

command line okay so let's just quickly

play04:56

learn how we do uh variables so so if I

play05:00

do make test and then I pass a variable

play05:03

uh then I want to use it actually heck

play05:06

let's use emojis right uh see if it

play05:09

supports it maybe it will crash there we

play05:11

go okay uh so we can pass parameters now

play05:14

all we have to do is Define something

play05:16

like add

play05:18

migration and make sure that we are

play05:20

capable of specifying a name uh let me

play05:23

remove all this space over here uh take

play05:26

the name parameter replace the in it

play05:28

with it and and now I can do very simple

play05:32

as long as I am in the same directory as

play05:35

the make file I can make add

play05:39

migration give it a name of init and

play05:43

there you have it so now you have

play05:46

effectively a reusable script that you

play05:48

can run from a command line and that is

play05:51

going to generate your migrations

play05:53

hopefully from this point on you can say

play05:55

okay uh I have a tool over here that

play05:59

allows me me to build up build up

play06:01

interactions with my project if you

play06:04

create a do GitHub folder and on the

play06:08

GitHub build machine make is most likely

play06:10

already going to be installed you can

play06:13

understand okay however I'm interacting

play06:14

with my project locally I can now

play06:17

actually transfer it to my build

play06:19

pipelines as well okay so your commands

play06:23

become reusable not only across your

play06:25

team not just to yourself you don't have

play06:27

to create an MD file at and you know

play06:30

save these commands in there and have

play06:32

the documentation you can just document

play06:34

the commands or you know uh these can be

play06:36

so easy to read you can just open the

play06:38

make file and see what it does anyway

play06:40

and that is pretty much it for the video

play06:44

so just a file with a bunch of recipes

play06:46

that you can invoke from a command line

play06:48

you can share them between teams or

play06:50

other computers so if you're running a

play06:52

GitHub workflow uh all of those things

play06:54

will be available there now please do

play06:56

leave a comment if you've ever used make

play06:59

yourself or a tool similar to make and

play07:02

obviously if you have any questions you

play07:03

can also leave that in the comment

play07:05

section don't forget if you enjoyed the

play07:06

video leave a like And subscribe not a

play07:08

lot of source code here but if you would

play07:09

like the source code please come support

play07:11

me on Patron Patron supporters are what

play07:14

helps me make these videos and I will

play07:16

actually make these videos possible so

play07:19

very very big thank you to all of my

play07:21

current Patron supporters and as always

play07:23

thank you for watching the video and

play07:24

have a good day

Rate This
β˜…
β˜…
β˜…
β˜…
β˜…

5.0 / 5 (0 votes)

Related Tags
Database Migrations.NET DevelopersProductivity ToolEF CoreMake ToolCommand LineCode EfficiencyDevOps PracticesGitHub WorkflowCross-Platform