
Install Visual Studio Code and the .NET SDK, choosing the correct operating system, and download dotnet 7 to prepare for creating a new web API.
Start a dotnet web api with watch and hot reload, access Swagger and the weather forecast get call, test routes, and view results in browser and developer tools.
The MVC pattern divides logic into model, view, and controller. The web API creates, updates, and deletes data, while the view renders results via UI and Swagger UI.
Create models for roleplaying game, a character class with id, name, hit points, strength, defense, intelligence, and an RPG class enum with knight, mage, cleric; then add controller and get.
create a new api character controller, derive from controller base, add api controller and route attributes, and implement a get method returning a mock knight character for swagger testing.
Define a route parameter for the single character endpoint and retrieve a character by ID using first or default with a lambda, tested in swagger.
Discover how http request methods map to crud in a .net 7 web api: use get for reading, post for creating, put for updating, and delete for removing, soft delete.
Add a new character with a post request by sending a JSON body to the API, then return the full character list to verify the update.
Structure a web api by delegating logic to services, injecting dependencies into controllers, and using DTOs to shape client data with mapped models, optionally via AutoMapper.
Create ICharacterService and CharacterService in a services folder, inject with add scoped in program.cs, and verify via swagger that get all characters returns Frodo and Sam.
Fix possible argument null exceptions by using first or default to fetch a character, check for null, return when found, or throw character not found, tested in swagger.
Discover how asynchronous calls free threads during tasks, and learn to implement async, Task, and await in the character service and controller, preparing for database queries with entity framework.
Wrap service results in a generic wrapper service response using generics to type the data, including data, isSuccessful, and message for clear front-end interceptors and error handling.
Create and use data transfer objects for RPG characters, including get character DTO and add character DTO; map between model and DTOs with AutoMapper in controllers and services.
Implement a put-based update for an RPG character by adding update character to the interface, service, and controller, using update character DTO and id, with null checks and not-found handling.
Learn how to update a character using AutoMapper by mapping the updated character to the character object and using the map overload. Configure an update map in the AutoMapper profile.
Explore object-relational mapping, where characters and skills map to tables and relationships in relational databases, and use code-first migration with entity framework to generate the database from your models.
Install essential EF Core packages, then install and verify the EF command-line tools globally to enable migrations in a net seven project.
Add a new RPG character to the database using context.Characters.Add and SaveChangesAsync, letting SQL Server generate the ID. Return all RPG characters after insertion and test with Swagger.
Fetch the character from the data context asynchronously, modify its properties, and save changes asynchronously using the put method, with the id remaining fixed.
Implement create, read, update, and delete operations with entity framework, use code-first migration and SQL Server, configure db context and connection string, and prepare for user-owned characters and authentication.
Build user authentication by creating accounts, defining a user model, linking multiple RPG characters to each user, and implementing JSON web tokens to verify access for selecting and updating characters.
Define a user model with id, username, and password hash and salt, register a DbSet in the data context, and create a relationship where users can have multiple rpg characters.
Explore authentication through the repository pattern, leveraging entity framework and a data context to decouple data access from the domain model and enable dependency injection.
The user exists method checks username duplicates using any async with a case-insensitive comparison, returning true or false; the register flow uses a service response to flag 'user already exists'.
Learn to build an authentication controller in a .NET 7 web API, inject an auth repository, and implement a register endpoint using a user register DTO to return the user id.
Implement token authentication with JSON web tokens to securely authorize web API requests, storing tokens in the browser, using claims, expiration, and server-side signing.
Configure app settings token and build a JWT with claims, a symmetric security key, and HMC SHA 512 signing. The token supports login, swagger testing, and authorization via middleware.
Enable bearer token testing in swagger by adding a security definition and operation filter using swashbuckler, configure authorization header, and demonstrate authorize and allow anonymous controls on secured controllers.
Leverage claims principle to extract the authenticated user's id, then filter character data by that user id in the Entity Framework service, test with swagger, and establish user-character relationships.
Learn to relate RPG characters to the authenticated user by injecting the http context accessor, extracting the user id from claims, and updating character service methods accordingly.
Assign the current authenticated user to a new character by mapping the add character dto, then filter results to return only that user's characters.
Enforce access control for get, delete, and update by filtering characters where the user id matches the current user, leveraging entity framework predicates.
Implement a weapon service to add weapons to RPG characters, update the get character DTO via mapping, and expose a secure controller that uses the current user context.
Fetch the authenticated user and display each user’s own characters. Implement a one-to-one weapon relationship and a many-to-many skills relationship with entity framework joining tables, and build services and controllers.
Develop a service that lets RPG characters attack with weapons or skills, then have characters fight by themselves until one loses hit points, ranking victories as a high score.
Map relationships among characters, weapons, and skills, add fights, victories, and defeats to the character model, and implement a fight service and controller for upcoming attack simulations.
Implement a fight system in net 7 web api, introducing fight request dto with character ids and fight result dto with a log, enabling rpg death matches and battle summaries.
Implement a high score feature by adding a high score DTO, mapping with AutoMapper, and exposing a GetHighScore method to rank fighters by fights, victories, and defeats.
Learn to build a .NET 7 web API with entity framework core, using the model-view-controller pattern, data transfer objects, async/await, authentication with JSON web tokens, migrations, CRUD, and relational databases.
Create a new web api with dotnet new web api, open the folder in Visual Studio Code, install recommended extensions, and explore the weather forecast controller and swagger.
Create and initialize a git repository, use a dotnet new gitignore to exclude unnecessary files, commit changes with clear messages, and push the project to GitHub.
Extend a .NET Web API project by adding a new controller and models for RPG characters, convert synchronous calls to asynchronous, and implement data transfer objects for practices in MVC.
Explore the mvc pattern by detailing the model, view, and controller and how the controller uses a web api to create, update, and delete data, persisting changes in the database.
Create a models folder with a character model and an RPG class enum (Knight, Mage, Cleric). Add properties id, name Frodo, hit points, strength, defense, intelligence, and a get endpoint.
Create a new api controller in a .net 7 web api, implement a get method returning a mock character, configure routing, return types, and json enum formatting for swagger.
Explore routing with parameters by retrieving an RPG character by id, wiring a get single method to match the route parameter, and test with urls like /characters/0 and /characters/1.
Explain how HTTP methods GET, POST, PUT, and DELETE map to CRUD operations, including how a soft delete can be implemented and how the backend updates a database.
Create a web API endpoint that adds a new character via HTTP POST, receiving a JSON body and returning the updated character list for testing in the API interface.
Learn how AutoMapper streamlines mapping in a .NET 7 Web API by installing the package, configuring profiles, injecting IMapper, and mapping character to get character DTO and add character DTO.
Implement a put update for a role-playing game character by adding update character dto and interface, map to get character dto in the service, and wire through the controller.
Learn to update a character with AutoMapper by mapping the update character DTO to the character and using partial versus full property updates, via the put method.
Implement a delete character operation by updating the interface, service, and controller, removing the character, mapping to DTOs, testing with swagger, and persisting with EF Core and SQL Server.
Build and explore a dotnet web api with full crud operations, leveraging mvc structure, dependency injection, asynchronous calls, and dto-based service responses, paving the way for entity framework core.
Learn to connect your web API to a database using Entity Framework Core, perform asynchronous CRUD operations, and persist RPG characters with code-first migrations on SQL Server Express.
Explore object-relational mapping by modeling characters and skills as code objects, while entity framework creates and updates database tables and relationships through code-first migration.
Install the entity framework core sql server provider and the dotnet-ef global tool, then add Microsoft.EntityFrameworkCore.Design to enable migrations, preparing the project for sql server.
Define a data context by creating a DbContext subclass with a DbSet<Character> to query and save RPG characters, embodying a unit of work and repository pattern.
Learn to wire a data context with dependency injection in the character service, fetch characters with EF Core and ToListAsync, map to a service response, and test endpoints in swagger.
Learn how to implement a post create endpoint in a .NET 7 web API using entity framework to add RPG characters, generate IDs, persist changes, and return all characters.
Use a put method to locate a character with FirstOrDefaultAsync from the data context, modify properties such as hit points, strength, and class, and save changes async; verify via swagger.
Replace the static characters with the context characters, delete the character, await the first async operation, save changes, and verify the deletion in swagger and the database.
Master CRUD with entity framework core, persisting changes via code-first migrations to a SQL Server database, and prepare to relate RPG characters to users with authentication.
Create a user model with id, username, password hash and salt as byte arrays, add it to the data context, and set up the relationship to RPG characters.
Explore three relation types and implement a one-to-many link between users and RPG characters by adding navigation properties, a user_id foreign key, and migrations to update the database, with authentication.
Explore how authentication uses the repository pattern with Entity Framework, injecting a data context through a repository interface to handle register, login, and user existence checks.
Implement an async user existence check with Entity Framework Core, using AnyAsync and case-insensitive username comparison, returning a 'user already exists' message in the register flow.
Create an authentication controller with a post /register endpoint that accepts a user register DTO, uses an auth repository to register a user, and returns 200 or 400.
Learn to implement JSON web tokens (JWT) for authentication in .NET 7 Web API, including configuring app settings, building claims, signing tokens, and validating expiration.
Extract the authenticated user's id from the claims principal and fetch that user's RPG characters using a filtered EF query, tested via swagger with a bearer token.
The .NET framework is getting better and better and more important in the web development world nowadays.
Almost every request I get for new web development projects is asking for knowledge in .NET, including Web API and Entity Framework.
So, knowing the fundamentals of back-end web development with .NET can be highly beneficial to your career. And that’s where this course comes in.
In a short period of time, you will learn how to set up a Web API, make restful calls to this Web API and also save data persistently with Entity Framework, Code-First Migration, a SQL Server database, and all three types of relationships in this database.
We will get right to the point, you will see every single step of writing the necessary code and by the end of this course, you will have what it takes to say ‘yes’ to all the .NET project requests from any recruiter.
The only tool you need in the beginning is Visual Studio Code which is available for free.
We will use Visual Studio Code for our implementations and make calls to the Web API with the help of Swagger UI - an interface that lets you consume the API out-of-the-box, thanks to the latest version of the .NET framework.
Later, we will also utilize SQL Server Express and the SQL Server Management Studio to manage our database. These are also available for free.
The back-end application we’re going to build is a small text-based role-playing game where different users can register (we’re going to use JSON web tokens for authentication) and create their own characters like a mage or a knight, add some skills and a weapon, and also let the characters fight against each other to see who is the best of them all.
What You Will Learn
Introduction
Create your first Web API call in less than 10 minutes
Initialize a Git repository for your source control
Web API
The Model-View-Controller (MVC) pattern
Create models and controllers
Attribute routing (with parameters)
The HTTP request methods GET, POST, PUT & DELETE
Best practices for your Web API like a ServiceResponse class and Data-Transfer-Objects (DTOs)
Map your models with AutoMapper
Entity Framework Core
Object-Relational-Mapping
Code-First Migration
SQL Server Express
How to use a DataContext and a proper ConnectionString
All previous HTTP requests with Entity Framework Core to save your data in a SQL Server database
Data Seeding: Insert data with a migration programmatically
Authentication
Token Authentication with JSON Web Tokens
Claims
Secure controllers with the Authorize attribute
Add roles to the users
Advanced Relationships with Entity Framework Core
One-to-one relationships
One-to-many relationships
Many-to-many relationships
Include entities with Entity Framework Core
Get the proper relations between entities
More Than Just CRUD
Start automatic fights
Filter and order RPG characters by their highscore
This course has been completely re-recorded with .NET 7.
The lectures with the older versions of the .NET (Core) Framework - .NET 6, 5 & .NET Core 3.1 - are still available for reference.
Your Instructor
My name is Patrick and I will be your instructor for this course. I’m a web developer for over a decade now, I have worked for big corporations and small teams, as an employee and a contractor and I just love to see the way Microsoft is going with .NET and how important it gets day by day.
To this date, I was able to run ten courses on web development here on Udemy about ASP.NET, Blazor, single-page applications, Angular, and DevOps, with a total of over 75.000 unique students and more than 10.000 reviews.
If you have any questions, feel free to connect.
And if you still have any doubts, you have a 30-day money-back guarantee, no questions asked.
So, I hope you’re ready for your new skills and your new projects! ;)
I’m looking forward to seeing you in the course!
Course image: practicuum/Shutterstock