
Explore what Entity Framework Core is for, its evolution, and code first and database first approaches, including when to use them and how to configure in console and split apps.
Learn how Entity Framework Core, the object-relational mapper, lets you represent database tables as objects and work with SQL Server, SQLite, PostgreSQL, MySQL, and Oracle without writing SQL.
Explain the annual November release cycle for Entity Framework Core, noting EF Core 6 (November 2021) and 7 (November 2022), with LTE three-year and non LTE two-year support.
Explore code first and database first approaches in entity framework core 6, enabling database creation from code or generating the necessary entities and classes to work with an existing database.
Assess when to use entity framework core, balancing productivity, speed improvements up to 90%, cross-platform support, and compatibility with SQL Server, PostgreSQL, MySQL, Oracle.
Identify when not to use EF Core six: framework four eight unsupported, databases, bulk scenarios where raw queries outperform EF Core; benchmark and consider Dapper or ADO.NET as alternatives.
Explore the trade-offs between EF Core 6 and Dapper, showing how a micro-ORM maps query results to C# objects and how compile models and optimizations boost speed and reduce memory.
Install EF Core CLI to run migrations and generate entities from an existing database. Explore installation steps, updating to the latest version, and using the CLI in Windows.
Configure EF Core in a console app by creating a DbContext and entities, wiring a connection string, installing packages, and applying migrations.
Learn to configure EF Core in an ASP.NET Core app by adding a DbContext, injecting it, and using a connection string from appsettings.json to connect to SQL Server.
Explore Entity Framework Core 6 for cross-platform data access across Windows, Linux, and macOS, using code-first and database-first approaches to generate and synchronize databases with diverse engines.
Learn code-first database modeling with ef core 6 by building a genre entity and movie concepts, configuring keys, string lengths, and defining three relationship types with conventions and data annotations.
Create a web api project for an Entity Framework Core 6 app. Define genres, actors, movies, and movie theaters, and configure EF Core with a SQL Server connection string.
Create genre entity with id and name, map it via a dbset to genres table, run migration to set id as primary key and name nullable, showing configuration by convention.
Explore how a primary key is configured by convention when a field is named id. Override this with data annotations or the fluent API, and manage migrations to apply changes.
Define a string property's max length to 150 using data annotations or the fluent api, then generate a migration to alter the column and observe data loss warnings.
Demonstrate enforcing a required name in entity framework core 6 using data annotations and fluent APIs, setting max length to 150, and applying migrations to create a not null column.
Learn to rename tables and schemas in entity framework core 6 using data annotations and the fluent api, including changing the table name, schema, and column name.
Create the actor entity with id, name, biography, and a nullable date of birth, and map it to the actors table. Configure the name as max length 150 and required, decide on date type mapping (date vs datetime) via annotations or fluent API, and apply migrations to update the database.
Create a cinema entity with name constrained to 150 characters and required, add location and price, and configure price precision 9 and scale 2 via the fluent API and migrations.
Learn to model spatial data in EF Core 6 with NetTopologySuite, storing cinema location as a point using SQL Server geography type, then migrate and update the database.
Create the movie entity in EF Core 6 with fluent API, configure title and poster URL with constraints and release date as date, then apply migrations to update movies table.
Explore how to model one-to-one relationships in entity framework core 6 using navigation properties, convention-based configuration, and foreign keys to link cinema and cinema offer.
Demonstrate one-to-many relationships in entity framework core 6 by linking a cinema to multiple cinema halls with cost, using navigation properties, collections, and migrations.
Model cinema hall types with an enum in Entity Framework Core 6, add an enum property to the cinema hall, and generate a migration storing the enum as an integer.
Learn to configure the cinema hall type column’s default value with the model builder and HasDefaultValue, so the default remains two dimensions across migrations without manual edits.
Explore how to model many-to-many relationships with skip navigation in entity framework core 6, linking movies and genres directly and cinema halls to movies via composite keys and migrations.
Implement many-to-many relations with a full-control intermediate entity, define a composite key for movie actor, and add fields such as character and order using fluent api and migrations.
Explore configuring conventions in entity framework core 6 to map datetime properties to date columns and apply default string max length 150 via configure conventions and model builder overrides.
Organize entity configurations by creating separate config classes implementing IEntityTypeConfiguration<T>, then apply all configurations in a single line using modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly()), promoting modular, scalable EF Core 6 setup.
Generate and inspect a database diagram for an Entity Framework Core 6 project by logging into SQL Server, selecting tables, and visualizing one-to-one, one-to-many, and many-to-many relationships.
Configure primary keys, string lengths, nullability, and spatial data using conventions, fluent API, or annotations, and define one-to-one, one-to-many, and many-to-many relationships with optional intermediate tables, via entity type configurations.
Learn to perform queries against our database, starting by inserting data, then using filters, ordering, grouping, taking, and skipping, plus ways to load related data with Popular Auto Mapper Library.
Seed data into an EF Core 6 database using data seeding and migrations, employing the model builder has data calls to populate genres, actors, cinemas, cinema halls, and movies.
Query the genre table using the EF Core context injected via dependency injection. Switch to asynchronous programming with ToListAsync and await, returning Task<IEnumerable<Genre>> for better database calls.
Optimize read-only queries in Entity Framework Core by using no tracking to avoid the performance cost of tracking loaded entities, and configure default query tracking behavior per query or globally.
Learn how to fetch the first record in EF Core 6 using First and FirstOrDefault, apply filters, handle no results, and return not found when needed.
filter genres with entity framework core 6 using where and lambda expressions to fetch multiple records. apply contains or starts with to match genres by name.
Explore pagination with IQueryable in Entity Framework Core 6, using skip and take to fetch page-based records, and encapsulate the logic in a reusable extension method.
Learn to fetch only required columns in Entity Framework Core 6 using projection, avoiding fields like biography, and use data transfer objects to optimize queries.
Learn to use AutoMapper to project queries in Entity Framework Core 6, configuring a mapping profile and using projection to fetch only the necessary columns such as id and name.
Learn how to query cinemas with a point location in entity framework core 6, map location to latitude and longitude with AutoMapper, and expose a cinema endpoint for maps.
Order cinemas by proximity to a location and filter those within two kilometers using a geometry factory to create points with latitude and longitude in entity framework core 6.
Explore loading related data with eager loading in Entity Framework Core 6 using navigation properties to fetch movie and genres. Handle circular dependencies by ignoring cycles via JSON options.
Apply then include to load cinema halls and their cinemas from movies in EF Core 6. Map genres, actors, and cinema data for projection.
Explore selecting and ordering related data in EF Core 6 by using include, applying descending name orders and filters like name contains 'M' with negation, for genres and cinema halls.
Explore loading related data for movies using AutoMapper or without it, populating genres, cinemas, and actors via cinema halls, and control the ordering by genre name and cinema hall name.
Use select loading to fetch specific movie columns and load related data like genres, cinemas, and actors; project results with anonymous types and order by genre.
Explore explicit loading in Entity Framework Core 6 by loading related data after the main entity, using load async, querying related data counts, and comparing with eager loading for performance.
Configure lazy loading in EF Core 6 by marking navigation properties as virtual and enabling lazy loading in the DbContext with the Microsoft.EntityFrameworkCore.Proxies package, then beware the plus one problem.
deactivate lazy loading in ef core 6 by removing lazy loading proxies and virtuals, then verify that select loading and eager loading work.
Group queries in entity framework core 6 by cinema status for movies, then project results into anonymous types, count groups, and flatten genre collections for clear, grouped outputs.
Build a dynamic movie filter endpoint using deferred execution to apply title, cinemas, upcoming releases, and genre filters only when provided.
Query data with filters, sorting, projections, grouping, taking and skipping in Entity Framework Core 6. Compare eager, select, explicit, and lazy loading, plus splitter loading and deferred execution for queries.
Master grading, updating, and deleting data using the connected model in Entity Framework Core 6. Learn about entity statuses, flexible mapping, inserts with related data, and soft deletes.
Explore connected and disconnected models in entity framework core 6, track changes with a single dv context or across clients, and manage entity states: added, modified, unchanged, deleted, detached.
Clean up the project by removing unused controllers, pagination, and lazy loading related code and packages, then compile to ensure the application builds correctly.
insert a genre record in entity framework core 6 by tracking the entity state and saving changes. post the genre via the API with its name and simple mapping.
Learn how to insert multiple records at once in Entity Framework Core 6 using add range and context range, updating entity states for genres and movies via an API.
Insert a cinema with its offer and halls using Entity Framework Core 6, including a geometry factory point for location and creating related navigation properties in one post.
Insert a cinema and its data using dto mappings in ef core 6, configure auto mapper for cinema, offers, and halls, and create a location point with longitude and latitude.
Insert a new movie linked to existing genres and cinema halls, map creation data, avoid duplicating genres, and set movie actors with proper order.
Explore flexible mapping in EF Core 6 by mapping both properties and fields to a column, enabling name transformations like capitalizing initials during insert.
Update records using the connected model with a single DbContext instance, loading a genre or actor, updating properties in memory, avoiding no-tracking, and calling save changes to persist the updates.
Learn how to update entities using the connected model in Entity Framework Core 6, compare it with the disconnected model, and see how SaveChangesAsync updates all columns.
Update records with related data in entity framework core 6 by loading related entities with include and updating both the principal entity and its related data in a single operation.
Learn to delete records in entity framework core 6 by changing the entity status with Remove and SaveChanges, and compare normal delete with soft delete to preserve data.
Implement soft delete by adding an is_deleted column and marking records as deleted, then implement a migration and a global query filter to hide them in EF Core 6.
Entity Framework Core 6 teaches query filters at the entity level, enabling soft delete handling and the ability to ignore filters to restore data.
Explore connected and disconnected models in entity framework core 6, and learn to use add, update, and remove with save changes, soft delete, flexible mapping, and query filters.
Explore advanced property configuration in Entity Framework Core, covering configuration modes, primary keys (including generated keys), ignored properties, indexes, value conversions, entities without keys, and shadow properties via API configurations.
Explore three configuration modes in Entity Framework Core 6: conventions, data annotations, and the fluent API for setting primary keys, required fields, and constraints.
Explore how EF Core 6 defines primary keys using integers or GUIDs, create a log entity, and compare auto-generated vs manual id strategies, including sequential GUIDs for performance.
Discover how to ignore properties and classes in entity framework core 6 using not mapped attributes or the model builder, preventing unwanted columns or tables.
Learn how to configure indexes in EF Core 6 to speed queries and enforce uniqueness, using data annotations or fluent API to index the genre name and apply migrations.
learn how to implement a filtered unique index on genre names to support soft deletes, allowing reuse of names when a record is marked as deleted.
Use value conversions to store enum values as strings in the database, apply a migration, and retrieve them as their numeric representations in code.
Learn to implement custom value conversions in entity framework core 6 by mapping a currency enum to symbols with a converter and applying it to the cinema hall currency property.
Learn how keyless entities let you express arbitrary query results as typed classes, centralizing queries with no-tracking options and configuring them in the context to access cinema data without location.
Map a view to a keyless entity in EF Core 6 to expose movie counts by genre, cinemas, and actors via a migration-created view and a controller endpoint.
Explore shadow properties in entity framework core 6 to access table columns without entity properties, read a created date via context entry, and order results by that value.
Use the fluent API to iterate entities and their properties. Configure the column to be non-unicode when a string property name contains url, showcasing metadata-driven customization beyond conventions.
Learn the three configuration types in Entity Framework Core: conventions, annotations, and API-based setup; define primary keys, unique indexes, value conversions, and shadow properties, plus reflection-based automation.
Learn to configure relationships between entities in entity framework core 6, set up three relationship types with conventions, data annotations, and Flow API, and manage delete behavior with owned entities.
Explore core relationship types in entity modeling, including 1-to-1, 1-to-many, and many-to-many, with cinema and cinema halls as examples. Understand principal keys, dependent entities, and navigation properties that link data.
clean up a leaner Entity Framework Core 6 project by removing unused code and redundant entity elements, then add a migration named clean and update the database.
Configure relationships by convention in EF Core 6 using navigation properties and foreign key naming to infer 1-to-1 and 1-to-many relations, and learn how conventions reduce boilerplate code.
Explain required and optional relationships in Entity Framework Core 6, showing cascade delete for dependents and how nullable foreign keys enable optional relationships.
Configure foreign keys in Entity Framework Core 6 with data annotations to customize key names, such as cinema id, and verify changes via migrations and runtime checks.
Learn to configure two relationships to the same class with the inverse property attribute, modeling sender and receiver, seeding data, and loading a person with messages.
Configure one-to-one relationships using the fluent API in entity framework core, learn the HasOne and navigation property concepts, and customize the foreign key to override conventions.
Configure a one-to-many relationship between cinema and cinema halls using the fluent API in Entity Framework Core 6. A cinema has many cinema halls; each cinema hall has one cinema.
Configure many-to-many using a custom join entity with the fluent API, define a composite key (movieId, actorId), and map one-to-many relationships from actor and movie to movieActor.
Configure a many-to-many relationship without an intermediate entity in EF Core 6 using skip navigation, customize the join table name (genres_movies), seed data, and review migration steps.
Configure on delete behaviors for dependent entities when the principal is deleted, choosing cascade, set null, no action, or restrict in EF Core 6.
Discover table splitting in Entity Framework Core 6, a technique to divide a wide table into cinema and cinema detail entities for selective data access.
Explore owned types to centralize an address as an own type and reuse it across entities like cinema and actor, customize column names, run migrations, and observe automatic data loading.
Model an abstract payment class and derive card payment and PayPal payment to map inheritance in a single table using a table-per-hierarchy strategy, with a payment type discriminator.
Explore table-per-type inheritance in Entity Framework Core 6, storing each derived class such as rentable movie and merchandising in its own table, from an abstract product.
Explore how principal and dependent entities relate in EF Core 6 using conventions and data annotations to configure relationships, with a single table or each class having its own table.
Phillip Gavilan introduces essential commands and migrations in the package manager console for entity framework core 6, covering get help, migration, migration bundles, executive migration, and database migrate.
Learn to use get-help in Visual Studio to explore entity framework commands, including migrations, and use the detail flag to view parameters like migration name, output directory, context, and project.
Add migrations with add-migration creates a migration class named after the migration, with up and down methods that apply or revert database changes, such as adding a column.
Push pending migrations to the database using the migration history table. Learn how to apply, revert, or target specific migrations and keep the database up to date.
Master removing migrations in Entity Framework Core 6, including fully removing migrations with force, reverting the database state, and partially reversing changes using a new migration.
Learn to list and inspect migrations with the get migration command, view which migrations are applied or pending, test with no database connection, and remove migrations as needed.
Learn how to delete a database with drop-database, including creating a test database, applying migrations, confirming deletion, and restoring the original state.
Modify migrations, which reflect model changes, by editing a migration to add a view before applying it so the database includes the change.
Learn how migration bundles package EF Core migrations into an executable to apply updates to databases, even on Docker or servers without the .NET Core runtime.
Learn how to generate a script that includes all migrations with migration-script, and why migration bundles provide safe, repeatable execution when migrations contain custom code.
Apply migrations in Entity Framework Core 6 from your application using the migrate function to run pending migrations, and learn about parallel execution risks, timeouts, debugging, and verifying migrations history.
Learn how compiled models in Entity Framework Core 6 can speed up the initial load for apps with many entities, while noting limitations and the need to measure gains.
Apply a database-first approach with entity framework core 6 to generate models and a context from a database, scaffold the context, and verify the application interface with a sample endpoint.
Master entity framework core 6 migrations by using get help and detail options, adding, removing, and applying migrations, and leveraging migration bundles, serial migrations, and model compilation for load times.
Explore the properties of the dv context and how to configure it with the configure method. Learn to update entity state, inject services, perform arbitrary queries, and manage transactions.
Explore the DbContext properties that enable database access, migrations, transactions, and executing arbitrary queries, and learn how the change tracker, model, and unique context identifier support tracking and debugging.
Clean up the codebase by removing unused models and bundles, refactoring configuration into a private method, extracting methods, and recompiling to ensure everything works.
Learn how to configure a DbContext with OnConfiguring when bypassing dependency injection, using the SQL Server provider and a connection string, with centralized EF Core options.
Learn to change an entity's state directly in Entity Framework Core 6 by setting the genre's status via context, explore current values and original values, and save changes.
Learn to update specific columns in entity framework core 6 by marking properties as modified, so changes affect only chosen fields like the name, while other columns remain unchanged.
Override save changes in EF Core 6 to implement an audit system with an auditable entity, automatically setting created by and modified by for added and modified entities.
Demonstrate injecting a user service into the DbContext via dependency injection, using an interface and a fake implementation, and registering it as scoped.
Explore state events in Entity Framework Core 6 by implementing a change tracker event handler, wiring state change and tracked events, and observing added to unchanged state transitions.
Learn saving changes events in Entity Framework Core 6, including saving changes, saved changes, and save changes failed; wire handlers and log messages to track add, modify, and delete operations.
Explore arbitrary queries in Entity Framework Core 6 to execute raw or interpolated sql for fetching, inserting, updating, and building data, with protection from sql injection.
Insert data with arbitrary queries in EF Core 6 using context.Database.Execute to run interpolated insert statements into genres. Skip save changes to keep created by and modified by unpopulated.
Learn how to centralize arbitrary queries in entity framework core 6 by mapping a view to a class and using ToSqlQuery to run the query, with optional filters.
Explore stored procedures with EF Core 6 by creating a search procedure and testing insert and get by id procedures with output parameters, highlighting non composable versus composable queries.
Entity framework core 6 uses transactions to keep operations atomic, such as inserting a cinema and its halls. A save changes call rolls back all inserts if any operation fails.
Use begin transaction to group multiple save changes into a single atomic operation, enabling rollback if a later step fails in an invoice and its details.
Learn how to customize the context with the configuring method, update specific entity states and metadata, and use save changes, events, arbitrary queries, and transactions to ensure consistent, complete data.
Explore advanced scenarios in entity framework core 6, including user defined functions, computed columns, and table sequences; manage concurrency with temporal tables and issue commands across projects.
Clean up the application context by removing unused constructors, services, and save changes overrides; adjust configuration and prepare the project for a cleaner, ready-to-compile state.
Explore user defined scalar functions in Entity Framework Core 6, covering creation, data seeding, migrations, and invoking these functions from the application context to compute invoice totals and averages.
Learn how to implement table-valued functions in Entity Framework Core 6 by mapping a movie with counts, configuring the function via migration builder, and using it in a controller endpoint.
Leverage computed columns in Entity Framework Core 6 to automatically compute totals from quantity and price, and configure stored or computed values via entity type configuration and migrations.
Learn to create a sequence for a column using EF Core 6, configure a default value with next value, and define the schema to guarantee no gaps.
Explore field-level concurrency handling in entity framework core 6 by using the concurrency check attribute on the genre name, preventing conflicting updates from two users.
Learn how concurrency attributes prevent field-level conflicts and how a row version column enables row-level concurrency in Entity Framework Core 6, with practical update examples.
Handle concurrency exceptions in Entity Framework Core 6 by presenting the current value, the database value, and the attempted value to the user, enabling an informed decision to continue.
Handle concurrency conflicts in asp.net core with entity framework core 6 using disconnected model by sending the row version through endpoint and performing field-level checks with original and new values.
Explore how temporal tables preserve a history of data changes with a current table and a history table, via the fluent API and migrations, including period start and end fields.
Explore inserting, updating, and deleting data in a temporal table and observe how the history table records prior values with period start and end, while inserts do not populate history.
Modify a genre multiple times to generate data in the temporal and history tables. Query temporal all to retrieve all versions with period start and end, then project results.
Learn to query historical data with temporal as of in Entity Framework Core 6. Retrieve a record's value on a specific date and review the history table.
Explore querying a date range in entity framework core 6 using temporal from two, leveraging from and to boundaries and intermediate values to retrieve items from start to end dates.
See how to identify data versions totally contained within a date range using temporal contained in, with tests showing how start/end boundaries affect containment.
Explore temporal between to query history data for the active record in a date range, noting end-date coincidences, contrasts with temporal from two, and gloss versus half-opening intervals.
Restore a deleted record by selecting a date from the temporal table, insert it back with the same or new id, and manage identity_insert to preserve history.
Learn to customize temporal table names and history table details in Entity Framework Core 6 by configuring start, period, and history column names and ensuring date time types in migrations.
Learn to use EF Core in a multi-project setup by placing DbContext in a data class library, linking it to a web API, and running migrations with the project option.
Explore user defined functions, scalar and table valued functions, and computed columns that automate values and save storage, while using temporal tables to track changes and organize projects with libraries.
Explore automated testing fundamentals, including unit testing, using a testing framework with a memory provider, and testing with a real database to overcome memory limitations.
Explore basic concepts of software testing, define what a test is, and explain why automated testing helps verify that software functions as intended.
Automated testing creates software that tests our software, enabling quick, independent checks even with external dependencies. It follows preparation, testing, and verification to ensure reliable results.
Learn to set up a test project, write automated unit tests with test methods and asserts, run and debug tests, and use mocks to test more complex classes.
Use a mark as a test double to substitute a logger, isolate the glass under test, and verify the log messages and call count in change tracker event handler tests.
Learn to use the in-memory provider to run fast, behavior-focused tests of EF Core contexts, while noting limitations and when a real database is needed.
Test the genre post method with an in-memory database, configuring a test context and mapper to verify successful creation and handle duplicates with a 400 bad request.
Test NetTopologySuite functionality with a real LocalDB database during integration tests. Initialize, migrate, and optionally wrap tests in transactions, then delete the database to keep the environment clean.
Explore automated testing concepts and unit tests for a unit of work, including dependency mocking and testing a single responsibility, using an in-memory database for fast EF Core validation.
In this course you will learn how to use Entity Framework Core 6 to talk to a database from C# code.
- We will learn to create databases from our C# code using the code-first technique.
- We will make a brief comparison with Dapper, to see what is the difference between each of these tools.
- We will see how to read, update, delete, and create data using Entity Framework Core.
- We will learn to work with relationships between our tables: One-to-many relationships, one-to-one relationships, and many-to-many relationships.
- We will use the Fluent API to configure the schema of our database.
- We will see how to use automatic tests in our Entity Framework Core projects.
- We will learn about the new features that Entity Framework Core 6 brings us.
- We will use functions such as Sum, Average and GroupBy, to perform operations on different records of a table.
- We will see how to execute stored procedures using Entity Framework Core.
- We will load the related data of our entities in different ways, using eager loading, explicit loading, select loading and lazy loading.
- We will learn that with deferred execution we can use interesting techniques to make our code more flexible and reusable.
- We will see techniques on how to correctly configure Entity Framework Core in ASP.NET Core, for example, we will see when we should use a pool to recycle the DbContext.