Simple and Effective tool for .NET developers
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
🛠️ 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.
📝 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
💡.NET
💡Entity Framework Core
💡database context
💡migrations
💡terminal
💡command line
💡syntax highlighting
💡variables
💡GitHub workflow
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
welcome back boys and girls in this
video I'm going to be sharing a tool
with you that I have personally found
very useful the tool is called make and
you don't have to be a net developer to
find it very useful it's just my videos
are for net that's why the video is
titled like that but net developers have
a special trait where if they see
something that's not Microsoft or it's
not C they're like I don't want to touch
it this toll is not part of the
Microsoft ecosystem it is not a sharp
tool however it is a very useful tool
and it's very simple to use so uh if you
want to see what it's about continue
watching otherwise don't forget if you
have any questions make sure to leave
them in the comment section don't forget
to leave a like And subscribe don't
forget to check out the description and
let's go ahead and get started so very
very simple application I have an app
and I have a database so uh the app is a
simple net 8 application we have a
reference to the database project and I
have Entity framework Core Design uh
database as a postgressql Entity
framework I have a model super simple
and we have a database context where we
have a DB set then in the program CS
over here I am just reg registering the
database context so on the surface super
simple we Define a database we
registered in the app now hopefully some
of you have run into this problem we
want to generate migrations so we would
open up a terminal and let me make it
maybe close the other one we will do net
EF
migrations add and then I don't know
something like initialize uh at this
point the tool will run and it will spit
out some command you will add this
command you will run it again and you'll
be like it doesn't work so what do you
do ultimately let's say after some
Googling after finding other videos
you're going to know that I need to
specify which project is going to be the
startup project which is going to be
running the queries and uh such and then
I want to specify which project is the
project that contains the database the
DB context where the migrations should
be generated so uh let's do this we're
going to do netf uh migrations ad and
again I'm going to do in it but this
time I'm going to be specifying a start
project which is going to be the app. Cs
project and then we're just going to be
specifying the database project where
the migrations should be generator right
so database CS project and there we go
now if I run this the migrations are
going to be generated and there they are
okay so I'm going to delete them
hopefully a command like this some of
you may be like I can remember it some
of you will be like I can't remember it
uh if you have have many different
database projects which database are you
using Etc are you going to get this
command consistently between what you're
typing locally and your cicd pipeline
you effectively want to have this chunk
to be reusable okay so we're literally
going to take this chunk collapse the
terminal and this is where the make tool
comes in what I'm going to do is I'm
going to switch to file system I'm going
to add a new file and I'm just going to
call it make file okay I will paste the
command over here and I'm going to
control forward slash so comment uh is a
hashtag in this file okay and from the
beginning jet brains doesn't have
support for make file but then it says
do you want a plugin because I
understand what this F is and I was like
yeah sure so now I have syntax
highlighting here so uh how does make
work uh let's say we are going to have a
command called test and you can see
writer is capable of running these
commands uh do note this is a tab
delimiter not space delimiter uh this is
a common issue that can occur if you are
basically putting spaces you have to
indent with tabs but ultimately we will
run a command like Echo and hello okay
I'll save this file I'll open the
terminal over here and I will make test
okay and there we go and it just runs
your command so super simple uh how you
install make if you are on a MacBook
like I am or a uh Linux machine it may
already be installed if you're on
Windows you can use chocolatey to
install make I think that's that will be
the simplest approach and yeah you
basically just have the make Tool uh now
another thing that you will probably
want to learn is the thing that you're
going to variate is this in it so you're
going to want to effectively have this
as a variable that you pass from the
command line okay so let's just quickly
learn how we do uh variables so so if I
do make test and then I pass a variable
uh then I want to use it actually heck
let's use emojis right uh see if it
supports it maybe it will crash there we
go okay uh so we can pass parameters now
all we have to do is Define something
like add
migration and make sure that we are
capable of specifying a name uh let me
remove all this space over here uh take
the name parameter replace the in it
with it and and now I can do very simple
as long as I am in the same directory as
the make file I can make add
migration give it a name of init and
there you have it so now you have
effectively a reusable script that you
can run from a command line and that is
going to generate your migrations
hopefully from this point on you can say
okay uh I have a tool over here that
allows me me to build up build up
interactions with my project if you
create a do GitHub folder and on the
GitHub build machine make is most likely
already going to be installed you can
understand okay however I'm interacting
with my project locally I can now
actually transfer it to my build
pipelines as well okay so your commands
become reusable not only across your
team not just to yourself you don't have
to create an MD file at and you know
save these commands in there and have
the documentation you can just document
the commands or you know uh these can be
so easy to read you can just open the
make file and see what it does anyway
and that is pretty much it for the video
so just a file with a bunch of recipes
that you can invoke from a command line
you can share them between teams or
other computers so if you're running a
GitHub workflow uh all of those things
will be available there now please do
leave a comment if you've ever used make
yourself or a tool similar to make and
obviously if you have any questions you
can also leave that in the comment
section don't forget if you enjoyed the
video leave a like And subscribe not a
lot of source code here but if you would
like the source code please come support
me on Patron Patron supporters are what
helps me make these videos and I will
actually make these videos possible so
very very big thank you to all of my
current Patron supporters and as always
thank you for watching the video and
have a good day
浏览更多相关视频
EntityFramework Core Migrations | ASP.NET CORE | CLI Migrations | Package Manager Console Migratio
Entity Framework Migrations Explained
Getting Started with .NET Upgrade Assistant [3 of 18] Migrating from ASP.NET to ASP.NET Core
What is Dev Time Orchestration in .NET Aspire?
Barbottina: che cos'è e come si realizza?
Generate C# Model from existing Microsoft SQL Server Database
5.0 / 5 (0 votes)