
Explore the basics and core concepts of Entity Framework Core from beginner to intermediate levels, with emphasis on new features and foundations.
Explore how object-relational mapping (ORM) bridges your objects and relational databases, enabling you to query and manipulate data using your language of choice with Entity Framework Core.
Explore entity framework core, the cross-platform, open-source ORM for .NET 7, enabling automated data access, model generation from database, secure queries, and flexible execution of stored procedures.
Install Visual Studio 2022 with .NET 7, then install SQL Server and SQL Server Management Studio to manage and examine tables.
Access course resources for the Entity Framework Core complete guide by visiting Dotnet mastery, downloading all resources and the complete project, and reviewing GitHub commits for each section and lecture.
create an mvc app in Visual Studio 2022, name project coding wiki, use dotnet seven with authentication none, and push to a GitHub repo coding wiki_f for entity framework core.
Explore building an n-tier solution with separate data access, model, and web projects in dotnet 7, wiring references for entity framework core.
Install and manage the NuGet packages for entity framework core, including sql server provider and design-time tools, across data access and a console project with a consistent dotnet 7 preview.
Create an application db context inheriting from db context, add a dbset for the book model, and define the book class with id, title, isbn, and price.
Override OnConfiguring in the DbContext to define the connection string, use the SQL Server provider, and supply a LocalDB connection string with trusted connections and certificate options.
Add a migration to create books table, define a primary key with [Key] or rely on EF Core conventions, and ensure startup project and default project generate the migration files.
Explore EF Core migrations: up and down create or drop the books table with book id as identity primary key, title, and price; nullable enabled and database creation follows.
Apply the added migration to create the books table, ensure the data access project is the default, and run update-database to generate and apply SQL.
Learn how entity framework core uses the migration history and migration ID to apply only pending migrations, guided by the application db context model snapshot.
Learn to remove a migration and update an existing table by changing the book price to decimal in code, then add and apply the migration with a 10,5 precision.
Practice adding a migration by creating a genre class with id, name, and display, then generate the genres table and apply the migration.
Remove the default nullable behavior in Dotnet seven and use string? to mark nullable properties, across all projects including the web project.
Add a genre class with id, name, and display properties, register it in the db context as genres, and update the database via migrations to create the genres table.
Learn how changing the project's nullable setting in EF Core affects table columns, as title and ISBN become nullable and migrations update their nullability, creating two tables.
Rename a column in Entity Framework Core by adding a migration, using the built-in rename after .NET 5, or fallback to migrationBuilder.Sql for older versions.
Add a migration for new classes or tables, new columns or properties, or deletions or modifications of properties; keep migrations small and never delete old migrations.
Roll back to a migration with EF Core by using package manager console and update-database, not for production due to data loss, then reapply migrations to return to latest version.
Learn to revert the last migration to restore a dropped genre table, then re-add it with a new migration, and manage empty or undo migrations in EF Core.
Learn to manage migrations with additional commands, including get-migration to list migrations and their applied status. Drop database deletes the database, while update database recreates it and applies all migrations.
Seed data using migration to populate books and genre tables through the application db context by using model builder has data, then add a migration and insert default book records.
Apply table and column data annotations to rename an EF Core table and its columns. Create and run migrations to update the SQL Server database accordingly.
Review the required and primary key data annotations, understand nullable settings on string properties, and practice renaming genre to category and applying migrations in EF Core.
enforce isbn length with the max length data annotation set to 20, and mark price range as not mapped since it is computed for the user interface.
Learn how to use EF Core power tools to generate database diagrams in SQL Server and Visual Studio, add tables, view relationships, and install the required NuGet package.
Create author, location, publisher, and subcategories tables with exact column names. Add migrations and update the database to implement a computed author full name and validations.
Create and configure author, publisher, and subcategory models in Entity Framework Core, define primary keys and validations, add a computed full name, register DbSets, run migrations, and prepare table relationships.
Learn to implement a one-to-one relation in EF Core by linking a book to its detail, with a mapping column id and a dedicated primary key in the detail.
Demonstrates configuring a one-to-one relationship in entity framework core by adding book detail, defining navigation properties, and aligning foreign keys to map a 1-to-1 relation between book and book detail.
Demonstrates correcting a one to one relation by placing the foreign key in the book detail table to reference the book, updating the diagram accordingly.
Implement a one-to-many relation by adding publisher_id to the books table and omitting mapping on publishers, so one publisher can publish many books, and each book has one publisher.
Configure a one-to-many relation by adding publisher_id as a foreign key on the book table and define the publisher navigation property, then apply migrations and explore cascade referential actions.
Demonstrate configuring a one-to-many relation between book and publisher in EF Core, including migrations, seeding publishers, setting publisher id, cascade delete, and loading related books via navigation properties.
Enable many to many relations in entity framework core five by skipping the mapping table, letting it create the author book intermediate table, and applying migrations and database updates.
Create a manual many-to-many mapping with a book author map, define a composite primary key using fluent API, and implement foreign keys and navigation properties for precise control.
Explore one-to-one, one-to-many, and many-to-many relation mappings in Entity Framework Core, with books and book details, including foreign keys, navigation properties, and automatic versus manual mapping with Fluent API.
Configure entities with the fluent API in a code-first approach, using OnModelCreating to replace data annotations and define composite keys.
Learn how fluent API renames tables and columns in onmodelcreating, achieving the same custom names as data annotations, using model builder, to table, and has column name, with migrations.
Define a single primary key and mark the book detail ID as required using fluent API in entity framework core, then rename the table and apply migrations.
Learn to configure not mapped properties and max length with fluent API in EF Core, including ignoring price range and enforcing ISBN constraints, then add migrations and update the database.
apply fluent api to author and publisher, replicate the book and book detail approach, include required, max length, and key not mapped, ignore categories and sub category, two publisher requirements.
Implement fluent API configurations and set up db sets for author and publisher, defining primary keys, required fields, and max length; create migrations and update the database.
Explore a one-to-one relationship using fluent api by mapping book and book detail, configuring the foreign key in book detail, and updating the migration and database.
Configure a one to many relation between book and publisher using model builder and fluent API, with the foreign key in the book and a migration to update the database.
Explore how to implement many-to-many relationships between authors and books using skip mapping tables in EF Core, leveraging fluent API navigation properties and migrations.
Learn to implement a many-to-many relationship with a manual mapping table for book and author, using a composite key and fluent API mappings in the db context.
See how smart Entity Framework Core is by handling a mapping table without a DbSet, then add a DbSet to access it and explore many-to-many relations.
Organize fluent API configurations by moving each entity into its own config class, then apply them in the DbContext to keep code clean and testable.
Access data with Entity Framework Core in a console app using the application DB context, EnsureCreated, and migrations via GetPendingMigrations and Migrate, then query the books table.
Use EF core to retrieve all books by creating a db context, querying the books db set with ToList, and displaying titles and ISBNs in a console app.
Learn to add a new book with EF Core: create the book, use the context add method, and save changes to persist, handling identity column and publisher foreign keys.
enable logging in entity framework core to reveal the actual select queries, configure console logging and log levels, and filter to show the database command to understand what EF executes.
Explore how to retrieve a single book with first and first or default, compare the exception when no records exist, and handle null results in EF Core.
Apply where filters to query data with Entity Framework Core, using first or default and multiple conditions like publisher id and price, to retrieve single or multiple books efficiently.
Use first or default with a direct link condition to fetch a single record, and parameterize user input to secure queries and prevent SQL injection in EF Core.
Call the Find method on the DbSet to retrieve a single entity by its primary key, such as passing 1002 for the book ID, returning the matched record.
Explore single and single or default in entity framework core, learn that single expects exactly one record and throws when multiple exist, while single or default returns null when none.
Explore how to filter data with contains and like operators in entity framework core, using where clauses and aggregate methods like max, min, and count to query ISBNs and prices.
Demonstrate deferred execution in Entity Framework Core, showing that .ToList() executes queries immediately while enumeration defers until access, and that FirstOrDefault, Single, and ToList may run immediately.
Learn to sort data with order by in Entity Framework Core, chaining then by to sort by title ascending and ISBN descending, including multiple sort conditions and conditional sorting.
Learn how to implement pagination with skip and take in Entity Framework Core, displaying subsets of records by page, skipping and taking the appropriate number of records.
Learn how EF Core tracks retrieved records and updates them by changing properties and calling save changes. See single and bulk updates by a where condition.
Learn how to delete a record in EF Core by retrieving the target entity with find, using remove, and calling context.SaveChanges to persist the deletion.
learn to convert synchronous methods to asynchronous ones in EF Core, using save changes async, find async, and get all books with skip and take, with Microsoft recommending async.
Set the web project as startup, register the application DbContext in program.cs, and configure EF Core with a sql server connection string from appsettings.json.
Seed categories by inserting records in the categories table via a migration, then run update database. Enable ef core command logging in appsettings.json and prepare a model-view-controller display of categories.
Create a category controller that injects the application db context, fetches all categories via the categories db set, and passes them to the index view.
Explore creating and updating categories with an upsert get action method in the category controller, handling id-based create or update, retrieving existing records, and rendering corresponding views.
Learn to create and update categories with EF Core by posting data, validating the model, using add or update on the db context, and saving changes.
Invoke the delete action method to load the category by id, remove it with EF Core, save changes asynchronously, and redirect to the index.
Learn how to handle an invalid id without throwing an exception by directing users to a not found page, replacing a sequence contains no element error with graceful user interface.
Learn how to avoid exceptions in assignment 4 by handling a non-existent category ID with first or default to return null and not found, and apply first in delete scenarios.
Explores bulk insert in EF Core by adding two and five categories, showing save changes outside the loop and using add range for batch inserts to optimize database calls.
Learn to remove multiple entities efficiently in EF Core by retrieving the top N categories with take, using remove range, and saving changes within a single transaction.
Learn to implement crud for author and publisher by building controllers and razor views, integrating jquery ui datepicker for birthdates, and setting up upsert forms in the underscore layout.
Explore CRUD operations for publishers and authors in EF Core, including creating, editing, deleting, and using a date picker for date of birth, and practice from scratch.
Demonstrates publisher and author create, read, update, delete operations in Entity Framework Core, mirroring the category pattern and configuring db sets for publishers and authors.
Implement book CRUD operations by converting the category controller to a book controller and building an index view that lists titles with create, edit, details, delete, and manage authors.
Learn how projections in EF Core convert full entities into view models, populate a publisher dropdown with select list items, and optimize upsert book operations by selecting only needed fields.
Build the book upsert view by wiring a Razor view to a book view model, implement a publisher dropdown from a publisher list, save changes, and verify the update workflow.
Implement upsert and delete operations in the book controller, enabling create, edit, and remove actions, while using projection to fetch only the needed publisher properties for dropdowns.
Explore explicit loading in EF Core to populate related publisher data for books on demand, reducing database round trips and improving efficiency.
Load the book details view by retrieving the book via the book view model, display and edit book detail fields in a Razor view, and ensure id validation.
Learn to update book details by populating the book id in book detail and handling create or update flows, resolving foreign key constraints when saving changes.
Learn how to use book details correctly in Entity Framework Core by leveraging the book detail model and navigation properties, avoiding unnecessary view model mappings for post and update flows.
learn how eager loading with include eliminates the N plus one problem by loading related publishers along with books in a single query, improving query efficiency.
Explore how EF Core defers queries until enumeration or access, showing when counts and full results trigger execution and how to optimize by fetching only what’s needed.
Learn the difference between IQueryable and IEnumerable in EF Core, showing how IQueryable applies where clauses on the database, while IEnumerable filters in memory, reducing server load.
Create a book author view model to manage multiple authors for a book, using the mapper and mapping table to display current and available authors via a dropdown.
Apply a not in LINQ clause through projection to fetch unassigned authors, then populate a dropdown with author IDs for a book and pass results to the view.
Demonstrates assigning and removing authors to a book via the book author map table and a dropdown. Implements post actions to add and remove associations and saves changes.
Remove author from a book using the many-to-many relation by identifying book and author IDs, removing the book-author map, and saving the changes.
Explore multi-level explicit loading by including the book author map and its authors, using collection loading to populate author objects and display full names.
Learn how eager loading with include and then include eliminates the n plus one problem by loading related entities in a single query using entity framework core.
Demonstrates enabling lazy loading proxies in EF Core, converting related properties to virtual, and illustrates the potential N+1 queries and extra database calls, urging careful use.
Load related data in Entity Framework Core with explicit, eager, or lazy loading. Prefer eager loading with include for a single query, and lazy loading via proxies.
Demonstrates EF Core change tracker tracking entity states from added to deleted as categories are retrieved, created, updated, and saved to the database, with DbSet interactions and state transitions.
Explore how Entity Framework Core tracks queries by default and how to apply no tracking for read-only data to improve performance.
Learn to retrieve data with views and stored procedures in EF Core by creating migrations, mapping views with a no-key model, and using a view-based db set for read-only queries.
Call and retrieve data from views and stored procedures using Entity Framework Core, applying filters and where conditions to view results and observe top records.
Execute raw SQL in EF Core using from SQL raw and from SQL interpolated on DB sets like books, authors, publishers. Avoid SQL injection with parameterization and explore stored procedures.
Execute a stored procedure with a parameter using from sql interpolated and exec to retrieve a book from a DbSet. The lecture outlines limitations and recommends Dapper for raw sql.
See how to change the default identity schema and table names in a dotnet identity mvc app using ef core, including model creating overrides.
Entity Framework is a term that goes hand by hand with ASP.NET Core. It is one of that technology that is used very often and is not understood most of the time.
This course will teach you everything you need to know about using Entity Framework Core with ASP.NET Core. The skills you will learn will help you to build and architect complex ASP.NET Core applications that make full use of Entity Framework Core with Code First. We will start with the basic fundamentals of Entity Framework Core and then we would dive into advanced concepts.
Unlike other courses, which are outdated or do not convert all the topics. I have especially taken care to keep the course updated as well as cover topics from beginner to advanced topics with Entity Framework Core.
By the end of watching this course, you'll be able to:
Understand the basics of Entity Framework Core
Use code-first migrations to push changes to the database, and learn how to manage them.
Override code-first conventions (using data annotations and fluent API)
Understand how LINQ works and how to filter data.
Add, update and remove objects
Apply best practices with Entity Framework
Understand relationships in Entity Framework Core
Bulk operations in Entity Framework Core
Change tracker, RAW SQL, Stored Procs, View, and much more.