Master technical and career interviews with structured answers—short definition, real examples, pitfalls, and how to answer in 60–90 seconds.
Short answer: Convert CLR types to database-compatible types and vice versa. Example: storing an enum as a string or encrypted data. Real-world example (ShopNest) ShopNest’s order service uses EF Core to save an Order an…
Short answer: Complex types that don’t have their own identity and lifecycle. Useful for grouping related properties (like Address inside a Customer). Real-world example (ShopNest) ShopNest’s order service uses EF Core t…
Short answer: When to use them? Complex types that don’t have their own identity and lifecycle. Useful for grouping related properties (like Address inside a Customer). Real-world example (ShopNest) ShopNest’s order serv…
Short answer: Private fields in your entity class mapped by EF Core instead of public properties. Useful for encapsulating domain logic and controlling property access. Transactions, Concurrency, Security Example code Pr…
Short answer: EF Core automatically wraps SaveChanges() calls in a transaction. Ensures all changes are committed atomically. For multiple SaveChanges() calls, transactions need manual handling. Real-world example (ShopN…
Short answer: Rollback) Use DbContext.Database.BeginTransaction() to start a transaction. Call Commit() to save changes or Rollback() to undo. Real-world example (ShopNest) ShopNest’s order service uses EF Core to save a…
Short answer: (BeginTransaction, Commit, Rollback) Use DbContext.Database.BeginTransaction() to start a transaction. Explain a bit more Call Commit() to save changes or Rollback() to undo. Useful for combining multiple o…
Short answer: Assumes conflicts are rare; detects conflicts when saving. Uses concurrency tokens (e.g., timestamp or row version) to detect if data was changed by another process. Say this in the interview Define — one c…
Short answer: How to implement it? Assumes conflicts are rare; detects conflicts when saving. Uses concurrency tokens (e.g., timestamp or row version) to detect if data was changed by another process. EF Core throws DbUp…
Short answer: Properties marked with [Timestamp] or configured as concurrency tokens. Stored in the database as rowversion/timestamp type or other markers. EF Core checks these tokens during updates/deletes to detect con…
Short answer: Catch DbUpdateConcurrencyException. Reload conflicting entity from database or merge changes. Retry operation or notify the user of conflict. Implement custom conflict resolution logic as needed. Testing, D…
Short answer: Unit Tests: Focus on logic without actual database. Use mocks or in-memory databases to isolate tests. Integration Tests: Use real database (or test instance) to validate EF Core behavior, migrations, and d…
Short answer: EF Core InMemory provider: Lightweight, fast, but doesn’t mimic relational database behavior exactly (no relational constraints, transactions). Other options: SQLite in-memory mode (better relational simula…
Short answer: Mock DbContext using libraries like Moq, but it can be complex due to EF internals. Better to abstract data access via repositories/interfaces, then mock those interfaces in tests. Alternatively, use in-mem…
Short answer: dd-Migration. Maintain separate migration history tables using MigrationsHistoryTable method. Apply migrations independently for each DbContext. Real-world example (ShopNest) When ShopNest adds a DiscountCo…
Short answer: Use separate migration folders per DbContext via the -Context option in Add-Migration. Maintain separate migration history tables using MigrationsHistoryTable method. Apply migrations independently for each…
Short answer: Configure DbContext in Startup or Program to select provider based on environment variables or config files. Use DI to inject correct connection strings and providers. Can use conditional compilation or env…
Short answer: Use migrations scripts with data transformation carefully. Apply backward-compatible schema changes first (add columns instead of drop). Use feature flags or phased deployment. Run migrations during mainten…
Short answer: Use IHostingEnvironment or config flags inside the DbContext OnModelCreating or after migration. Separate seed classes or methods per environment. Use EF Core’s HasData method or custom seed logic at runtim…
Short answer: Use [JsonIgnore] or ReferenceLoopHandling.Ignore in JSON serialization. Use DTOs without circular refs for API responses. Carefully design navigation properties to avoid cycles or use explicit loading. Real…
Short answer: lso Employee)? Define navigation property and foreign key for self-reference. Use Fluent API: .HasOne(e => e.Manager).WithMany(e => e.Subordinates). lso Employee)? Define navigation property and forei…
Short answer: Define navigation property and foreign key for self-reference. Use Fluent API: .HasOne(e => e.Manager).WithMany(e => e.Subordinates). Example code Define navigation property and foreign key for self-r…
Short answer: Use FromSqlRaw or FromSqlInterpolated for stored procedures and views. Map views as query types or entities without keys (read-only). For insert/update via SP, call them directly from DbContext. Real-world…
Short answer: Throws InvalidOperationException or returns null since no tracking or lazy loading. Need to attach entity or explicitly load navigation properties. Example code Throws InvalidOperationException or returns n…
Short answer: Use context.Entry(entity).State = EntityState.Detached. Useful to avoid tracking or to simulate detached state. Real-world example (ShopNest) ShopNest’s order service uses EF Core to save an Order and its l…
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: Convert CLR types to database-compatible types and vice versa. Example: storing an enum as a string or encrypted data.
ShopNest’s order service uses EF Core to save an Order and its line items in one SaveChangesAsync() call inside a transaction.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: Complex types that don’t have their own identity and lifecycle. Useful for grouping related properties (like Address inside a Customer).
ShopNest’s order service uses EF Core to save an Order and its line items in one SaveChangesAsync() call inside a transaction.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: When to use them? Complex types that don’t have their own identity and lifecycle. Useful for grouping related properties (like Address inside a Customer).
ShopNest’s order service uses EF Core to save an Order and its line items in one SaveChangesAsync() call inside a transaction.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: Private fields in your entity class mapped by EF Core instead of public properties. Useful for encapsulating domain logic and controlling property access. Transactions, Concurrency, Security
Private fields in your entity class mapped by EF Core instead of public properties. Useful for encapsulating domain logic and controlling property access. Transactions, Concurrency, Security
ShopNest’s order service uses EF Core to save an Order and its line items in one SaveChangesAsync() call inside a transaction.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: EF Core automatically wraps SaveChanges() calls in a transaction. Ensures all changes are committed atomically. For multiple SaveChanges() calls, transactions need manual handling.
ShopNest’s order service uses EF Core to save an Order and its line items in one SaveChangesAsync() call inside a transaction.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: Rollback) Use DbContext.Database.BeginTransaction() to start a transaction. Call Commit() to save changes or Rollback() to undo.
ShopNest’s order service uses EF Core to save an Order and its line items in one SaveChangesAsync() call inside a transaction.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: (BeginTransaction, Commit, Rollback) Use DbContext.Database.BeginTransaction() to start a transaction.
Call Commit() to save changes or Rollback() to undo. Useful for combining multiple operations that should succeed or fail as a unit. using var transaction = context.Database.BeginTransaction(); try { // Perform multiple operations context.SaveChanges(); transaction.Commit(); } catch { transaction.Rollback(); throw; }
ShopNest’s order service uses EF Core to save an Order and its line items in one SaveChangesAsync() call inside a transaction.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: Assumes conflicts are rare; detects conflicts when saving. Uses concurrency tokens (e.g., timestamp or row version) to detect if data was changed by another process.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: How to implement it? Assumes conflicts are rare; detects conflicts when saving. Uses concurrency tokens (e.g., timestamp or row version) to detect if data was changed by another process. EF Core throws DbUpdateConcurrencyException if a conflict occurs.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: Properties marked with [Timestamp] or configured as concurrency tokens. Stored in the database as rowversion/timestamp type or other markers. EF Core checks these tokens during updates/deletes to detect concurrent changes.
ShopNest’s order service uses EF Core to save an Order and its line items in one SaveChangesAsync() call inside a transaction.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: Catch DbUpdateConcurrencyException. Reload conflicting entity from database or merge changes. Retry operation or notify the user of conflict. Implement custom conflict resolution logic as needed. Testing, Deployment, Tools
ShopNest’s order service uses EF Core to save an Order and its line items in one SaveChangesAsync() call inside a transaction.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: Unit Tests: Focus on logic without actual database. Use mocks or in-memory databases to isolate tests. Integration Tests: Use real database (or test instance) to validate EF Core behavior, migrations, and data persistence. Tests cover CRUD operations, queries, and business logic using EF Core.
ShopNest’s order service uses EF Core to save an Order and its line items in one SaveChangesAsync() call inside a transaction.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: EF Core InMemory provider: Lightweight, fast, but doesn’t mimic relational database behavior exactly (no relational constraints, transactions). Other options: SQLite in-memory mode (better relational simulation). Use InMemory for unit tests; SQLite for more realistic integration testing.
ShopNest’s order service uses EF Core to save an Order and its line items in one SaveChangesAsync() call inside a transaction.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: Mock DbContext using libraries like Moq, but it can be complex due to EF internals. Better to abstract data access via repositories/interfaces, then mock those interfaces in tests. Alternatively, use in-memory or SQLite database for integration tests instead of mocking DbContext. Miscellaneous / Scenario / Trick Questions
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: dd-Migration. Maintain separate migration history tables using MigrationsHistoryTable method. Apply migrations independently for each DbContext.
When ShopNest adds a DiscountCode column, you create a migration, review the SQL, then apply it on staging before production.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: Use separate migration folders per DbContext via the -Context option in Add-Migration. Maintain separate migration history tables using MigrationsHistoryTable method. Apply migrations independently for each DbContext.
When ShopNest adds a DiscountCode column, you create a migration, review the SQL, then apply it on staging before production.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: Configure DbContext in Startup or Program to select provider based on environment variables or config files. Use DI to inject correct connection strings and providers. Can use conditional compilation or environment-based settings.
ShopNest’s order service uses EF Core to save an Order and its line items in one SaveChangesAsync() call inside a transaction.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: Use migrations scripts with data transformation carefully. Apply backward-compatible schema changes first (add columns instead of drop). Use feature flags or phased deployment. Run migrations during maintenance windows or use rolling updates.
When ShopNest adds a DiscountCode column, you create a migration, review the SQL, then apply it on staging before production.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: Use IHostingEnvironment or config flags inside the DbContext OnModelCreating or after migration. Separate seed classes or methods per environment. Use EF Core’s HasData method or custom seed logic at runtime.
ShopNest’s order service uses EF Core to save an Order and its line items in one SaveChangesAsync() call inside a transaction.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: Use [JsonIgnore] or ReferenceLoopHandling.Ignore in JSON serialization. Use DTOs without circular refs for API responses. Carefully design navigation properties to avoid cycles or use explicit loading.
ShopNest’s order service uses EF Core to save an Order and its line items in one SaveChangesAsync() call inside a transaction.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: lso Employee)? Define navigation property and foreign key for self-reference. Use Fluent API: .HasOne(e => e.Manager).WithMany(e => e.Subordinates). lso Employee)? Define navigation property and foreign key for self-reference. Use Fluent API: .HasOne(e => e.Manager).WithMany(e => e.Subordinates). lso Employee)? Define navigation property and foreign key for… self-reference. Use Fluent API: .HasOne(e =>…
e.Manager).WithMany(e => e.Subordinates). lso Employee)? Define navigation property and foreign key for self-reference. Use Fluent API: .HasOne(e => e.Manager).WithMany(e => e.Subordinates).
ShopNest’s order service uses EF Core to save an Order and its line items in one SaveChangesAsync() call inside a transaction.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: Define navigation property and foreign key for self-reference. Use Fluent API: .HasOne(e => e.Manager).WithMany(e => e.Subordinates).
Define navigation property and foreign key for self-reference. Use Fluent API: .HasOne(e => e.Manager).WithMany(e => e.Subordinates).
ShopNest’s order service uses EF Core to save an Order and its line items in one SaveChangesAsync() call inside a transaction.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: Use FromSqlRaw or FromSqlInterpolated for stored procedures and views. Map views as query types or entities without keys (read-only). For insert/update via SP, call them directly from DbContext.
ShopNest’s order service uses EF Core to save an Order and its line items in one SaveChangesAsync() call inside a transaction.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: Throws InvalidOperationException or returns null since no tracking or lazy loading. Need to attach entity or explicitly load navigation properties.
Throws InvalidOperationException or returns null since no tracking or lazy loading. Need to attach entity or explicitly load navigation properties.
ShopNest’s order service uses EF Core to save an Order and its line items in one SaveChangesAsync() call inside a transaction.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: Use context.Entry(entity).State = EntityState.Detached. Useful to avoid tracking or to simulate detached state.
ShopNest’s order service uses EF Core to save an Order and its line items in one SaveChangesAsync() call inside a transaction.
Install Toolliyo like an app Free
Home-screen access to tutorials, coding practice & career tools — no app store needed.
On iPhone/iPad: tap Share then Add to Home Screen.