Skip to main content

Command Palette

Search for a command to run...

๐—˜๐—™ ๐—–๐—ผ๐—ฟ๐—ฒ ๐—–๐—ต๐—ฎ๐—น๐—น๐—ฒ๐—ป๐—ด๐—ฒ๐˜€ ๐˜„๐—ถ๐˜๐—ต ๐—ง๐—ฟ๐—ถ๐—ด๐—ด๐—ฒ๐—ฟ๐˜€ ๐—ถ๐—ป ๐—˜๐˜…๐—ฝ๐—ฒ๐—ป๐˜€๐—ฒ๐˜€ ๐—ง๐—ฎ๐—ฏ๐—น๐—ฒ & ๐—›๐—ผ๐˜„ ๐—œ ๐—™๐—ถ๐˜…๐—ฒ๐—ฑ ๐—ง๐—ต๐—ฒ๐—บ ๐Ÿš€

Published
โ€ข1 min readโ€ขView as Markdown

Working with ๐—˜๐—™ ๐—–๐—ผ๐—ฟ๐—ฒ on an ๐—˜๐˜…๐—ฝ๐—ฒ๐—ป๐˜€๐—ฒ๐˜€ ๐˜๐—ฎ๐—ฏ๐—น๐—ฒ that had ๐—œ๐—ก๐—ฆ๐—˜๐—ฅ๐—ง, ๐—จ๐—ฃ๐——๐—”๐—ง๐—˜, ๐—ฎ๐—ป๐—ฑ ๐——๐—˜๐—Ÿ๐—˜๐—ง๐—˜ ๐˜๐—ฟ๐—ถ๐—ด๐—ด๐—ฒ๐—ฟ๐˜€ came with unexpected challenges. Hereโ€™s what I faced and how I solved them.

1๏ธโƒฃ ๐—œ๐—ป๐˜€๐—ฒ๐—ฟ๐˜ ๐—ก๐—ผ๐˜ ๐—ช๐—ผ๐—ฟ๐—ธ๐—ถ๐—ป๐—ด (๐—ก๐—ผ ๐—˜๐—ฟ๐—ฟ๐—ผ๐—ฟ๐˜€, ๐—ก๐—ผ ๐—ฅ๐—ฒ๐—ฐ๐—ผ๐—ฟ๐—ฑ๐˜€)

  • ๐—œ๐˜€๐˜€๐˜‚๐—ฒ: DbSet.Add(entity) and SaveChangesAsync() executed successfully, but records ๐˜„๐—ฒ๐—ฟ๐—ฒ๐—ปโ€™๐˜ ๐—ถ๐—ป๐˜€๐—ฒ๐—ฟ๐˜๐—ฒ๐—ฑ into the database.

  • ๐—™๐—ถ๐˜…: Used ExecuteSqlRaw() instead of EF Coreโ€™s Add() method.

2๏ธโƒฃ ๐—จ๐—ฝ๐—ฑ๐—ฎ๐˜๐—ฒ ๐—™๐—ฎ๐—ถ๐—น๐—ถ๐—ป๐—ด ๐˜„๐—ถ๐˜๐—ต ๐—–๐—ผ๐—ป๐—ป๐—ฒ๐—ฐ๐˜๐—ถ๐—ผ๐—ป ๐—–๐—น๐—ผ๐˜€๐—ฒ๐—ฑ ๐—˜๐—ฟ๐—ฟ๐—ผ๐—ฟ

  • ๐—œ๐˜€๐˜€๐˜‚๐—ฒ: ExecuteSqlRaw() for updating records resulted in "๐—œ๐—ป๐˜ƒ๐—ฎ๐—น๐—ถ๐—ฑ ๐—ผ๐—ฝ๐—ฒ๐—ฟ๐—ฎ๐˜๐—ถ๐—ผ๐—ป. ๐—ง๐—ต๐—ฒ ๐—ฐ๐—ผ๐—ป๐—ป๐—ฒ๐—ฐ๐˜๐—ถ๐—ผ๐—ป ๐—ถ๐˜€ ๐—ฐ๐—น๐—ผ๐˜€๐—ฒ๐—ฑ."

  • ๐—™๐—ถ๐˜…: Opened the database connection manually before executing the query.

3๏ธโƒฃ ๐——๐—ฏ๐—–๐—ผ๐—ป๐˜๐—ฒ๐˜…๐˜ ๐——๐—ถ๐˜€๐—ฝ๐—ผ๐˜€๐—ฒ๐—ฑ ๐—•๐—ฒ๐—ณ๐—ผ๐—ฟ๐—ฒ ๐—ฆ๐—ฎ๐˜ƒ๐—ฒ๐—–๐—ต๐—ฎ๐—ป๐—ด๐—ฒ๐˜€๐—”๐˜€๐˜†๐—ป๐—ฐ()

  • ๐—œ๐˜€๐˜€๐˜‚๐—ฒ: _context was getting disposed before SaveChangesAsync() when performing updates.

  • ๐—™๐—ถ๐˜…: Ensured DbContext was properly injected and used ๐˜๐—ฟ๐—ฎ๐—ป๐˜€๐—ฎ๐—ฐ๐˜๐—ถ๐—ผ๐—ป๐˜€ where necessary.

4๏ธโƒฃ ๐—ง๐—ฟ๐—ถ๐—ด๐—ด๐—ฒ๐—ฟ๐˜€ ๐—•๐—น๐—ผ๐—ฐ๐—ธ๐—ถ๐—ป๐—ด ๐—˜๐—™ ๐—–๐—ผ๐—ฟ๐—ฒโ€™๐˜€ ๐——๐—ฒ๐—ณ๐—ฎ๐˜‚๐—น๐˜ ๐—•๐—ฒ๐—ต๐—ฎ๐˜ƒ๐—ถ๐—ผ๐—ฟ

  • ๐—œ๐˜€๐˜€๐˜‚๐—ฒ: Triggers caused EF Core to ๐—ฒ๐˜…๐—ฝ๐—ฒ๐—ฐ๐˜ ๐—ผ๐˜‚๐˜๐—ฝ๐˜‚๐˜ ๐—ณ๐—ฟ๐—ผ๐—บ ๐—ผ๐—ฝ๐—ฒ๐—ฟ๐—ฎ๐˜๐—ถ๐—ผ๐—ป๐˜€, leading to exceptions.

  • ๐—™๐—ถ๐˜…: Used ExecuteSqlRaw() for INSERT, UPDATE, and DELETE operations instead of EF Core methods.

โœ… ๐—Ÿ๐—ฒ๐˜€๐˜€๐—ผ๐—ป๐˜€ ๐—Ÿ๐—ฒ๐—ฎ๐—ฟ๐—ป๐—ฒ๐—ฑ

  • ๐—˜๐—™ ๐—–๐—ผ๐—ฟ๐—ฒ'๐˜€ ๐—ฑ๐—ฒ๐—ณ๐—ฎ๐˜‚๐—น๐˜ ๐—ฏ๐—ฒ๐—ต๐—ฎ๐˜ƒ๐—ถ๐—ผ๐—ฟ ๐˜€๐˜๐—ฟ๐˜‚๐—ด๐—ด๐—น๐—ฒ๐˜€ ๐˜„๐—ถ๐˜๐—ต ๐˜๐—ฎ๐—ฏ๐—น๐—ฒ๐˜€ ๐—ต๐—ฎ๐˜ƒ๐—ถ๐—ป๐—ด ๐—ฑ๐—ฎ๐˜๐—ฎ๐—ฏ๐—ฎ๐˜€๐—ฒ ๐˜๐—ฟ๐—ถ๐—ด๐—ด๐—ฒ๐—ฟ๐˜€.

  • ๐—จ๐˜€๐—ถ๐—ป๐—ด ๐—˜๐˜…๐—ฒ๐—ฐ๐˜‚๐˜๐—ฒ๐—ฆ๐—พ๐—น๐—ฅ๐—ฎ๐˜„() ๐—ฏ๐˜†๐—ฝ๐—ฎ๐˜€๐˜€๐—ฒ๐˜€ ๐—˜๐—™ ๐—–๐—ผ๐—ฟ๐—ฒ'๐˜€ ๐—น๐—ถ๐—บ๐—ถ๐˜๐—ฎ๐˜๐—ถ๐—ผ๐—ป๐˜€ ๐˜„๐—ต๐—ฒ๐—ป ๐—ฑ๐—ฒ๐—ฎ๐—น๐—ถ๐—ป๐—ด ๐˜„๐—ถ๐˜๐—ต ๐˜๐—ฟ๐—ถ๐—ด๐—ด๐—ฒ๐—ฟ๐˜€.

  • ๐— ๐—ฎ๐—ป๐˜‚๐—ฎ๐—น๐—น๐˜† ๐—บ๐—ฎ๐—ป๐—ฎ๐—ด๐—ถ๐—ป๐—ด ๐˜๐—ฟ๐—ฎ๐—ป๐˜€๐—ฎ๐—ฐ๐˜๐—ถ๐—ผ๐—ป๐˜€ ๐—ฎ๐—ป๐—ฑ ๐—ฐ๐—ผ๐—ป๐—ป๐—ฒ๐—ฐ๐˜๐—ถ๐—ผ๐—ป๐˜€ ๐—ถ๐˜€ ๐—ป๐—ฒ๐—ฐ๐—ฒ๐˜€๐˜€๐—ฎ๐—ฟ๐˜† ๐—ถ๐—ป ๐˜€๐—ผ๐—บ๐—ฒ ๐—ฐ๐—ฎ๐˜€๐—ฒ๐˜€.

โ“ ๐—›๐—ผ๐˜„ ๐——๐—ผ ๐—ฌ๐—ผ๐˜‚ ๐—›๐—ฎ๐—ป๐—ฑ๐—น๐—ฒ ๐—˜๐—™ ๐—–๐—ผ๐—ฟ๐—ฒ ๐˜„๐—ถ๐˜๐—ต ๐——๐—ฎ๐˜๐—ฎ๐—ฏ๐—ฎ๐˜€๐—ฒ ๐—ง๐—ฟ๐—ถ๐—ด๐—ด๐—ฒ๐—ฟ๐˜€? ๐—›๐—ฎ๐˜ƒ๐—ฒ ๐˜†๐—ผ๐˜‚ ๐—ณ๐—ฎ๐—ฐ๐—ฒ๐—ฑ ๐˜€๐—ถ๐—บ๐—ถ๐—น๐—ฎ๐—ฟ ๐—ถ๐˜€๐˜€๐˜‚๐—ฒ๐˜€ ๐˜„๐—ถ๐˜๐—ต ๐—˜๐—™ ๐—–๐—ผ๐—ฟ๐—ฒ ๐—ฎ๐—ป๐—ฑ ๐—ฑ๐—ฎ๐˜๐—ฎ๐—ฏ๐—ฎ๐˜€๐—ฒ ๐˜๐—ฟ๐—ถ๐—ด๐—ด๐—ฒ๐—ฟ๐˜€? ๐—›๐—ผ๐˜„ ๐—ฑ๐—ถ๐—ฑ ๐˜†๐—ผ๐˜‚ ๐˜€๐—ผ๐—น๐˜ƒ๐—ฒ ๐˜๐—ต๐—ฒ๐—บ? ๐—Ÿ๐—ฒ๐˜โ€™๐˜€ ๐—ฑ๐—ถ๐˜€๐—ฐ๐˜‚๐˜€๐˜€! ๐Ÿ‘‡

More from this blog

๐—ฃ๐—ฎ๐˜€๐˜€๐˜„๐—ผ๐—ฟ๐—ฑ๐—น๐—ฒ๐˜€๐˜€ ๐—”๐˜‚๐˜๐—ต๐—ฒ๐—ป๐˜๐—ถ๐—ฐ๐—ฎ๐˜๐—ถ๐—ผ๐—ป ๐—ฅ๐—ฒ๐˜ƒ๐—ผ๐—น๐˜‚๐˜๐—ถ๐—ผ๐—ป

Passwords are the weakest link โ€” and .NET 10 just made it easier to remove them. With built-in support for passkeys and WebAuthn, you can authenticate users securely without storing a single password. .NET 10 introduces native passwordless authentica...

Nov 4, 20251 min read

.๐—ก๐—˜๐—ง ๐Ÿญ๐Ÿฌ ๐— ๐—ฎ๐—ธ๐—ฒ๐˜€ ๐—Ÿ๐—˜๐—™๐—ง & ๐—ฅ๐—œ๐—š๐—›๐—ง ๐—๐—ผ๐—ถ๐—ป๐˜€ ๐—˜๐—ฎ๐˜€๐—ถ๐—ฒ๐—ฟ ๐—ง๐—ต๐—ฎ๐—ป ๐—˜๐˜ƒ๐—ฒ๐—ฟ!

If youโ€™ve ever struggled to write complex LEFT JOINs in LINQ, youโ€™ll love whatโ€™s coming in .NET 10. No more juggling SelectMany, GroupJoin, and DefaultIfEmpty โ€” Microsoft just made it clean, readable, and developer-friendly! In .NET 10, LINQ gets fir...

Nov 1, 20251 min read

๐Ÿ”ฅ .๐—ก๐—˜๐—ง ๐—™๐—ฟ๐—ฎ๐—บ๐—ฒ๐˜„๐—ผ๐—ฟ๐—ธ ๐˜ƒ๐˜€ .๐—ก๐—˜๐—ง ๐—–๐—ผ๐—ฟ๐—ฒ โ€” ๐—ž๐—ฒ๐˜† ๐——๐—ถ๐—ณ๐—ณ๐—ฒ๐—ฟ๐—ฒ๐—ป๐—ฐ๐—ฒ๐˜€ ๐—˜๐˜…๐—ฝ๐—น๐—ฎ๐—ถ๐—ป๐—ฒ๐—ฑ

If youโ€™re preparing for a .NET developer interview, this is one question you canโ€™t afford to miss! Letโ€™s break down the core differences that every developer should know ๐Ÿ‘‡ 1๏ธโƒฃ Platform Support โ€“ .NET Framework works only on Windows, while .NET Core ...

Oct 30, 20252 min read

๐—˜๐—ฎ๐—ด๐—ฒ๐—ฟ ๐˜ƒ๐˜€ ๐—Ÿ๐—ฎ๐˜‡๐˜† ๐—Ÿ๐—ผ๐—ฎ๐—ฑ๐—ถ๐—ป๐—ด

In ๐—˜๐—ป๐˜๐—ถ๐˜๐˜† ๐—™๐—ฟ๐—ฎ๐—บ๐—ฒ๐˜„๐—ผ๐—ฟ๐—ธ ๐—–๐—ผ๐—ฟ๐—ฒ, how and when related data is fetched matters โ€” thatโ€™s where ๐—˜๐—ฎ๐—ด๐—ฒ๐—ฟ ๐—Ÿ๐—ผ๐—ฎ๐—ฑ๐—ถ๐—ป๐—ด and ๐—Ÿ๐—ฎ๐˜‡๐˜† ๐—Ÿ๐—ผ๐—ฎ๐—ฑ๐—ถ๐—ป๐—ด come in. ๐—˜๐—ฎ๐—ด๐—ฒ๐—ฟ ๐—Ÿ๐—ผ๐—ฎ๐—ฑ๐—ถ๐—ป๐—ด means related data is loaded immediately with the main e...

Oct 29, 20251 min read

Visual Studio Updates

89 posts