<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Javid KoluRazhan</title>
    <description>The latest articles on DEV Community by Javid KoluRazhan (@razhan1994).</description>
    <link>https://dev.to/razhan1994</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F782767%2F37b415a6-8656-43f6-a4a8-5174b21542df.png</url>
      <title>DEV Community: Javid KoluRazhan</title>
      <link>https://dev.to/razhan1994</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/razhan1994"/>
    <language>en</language>
    <item>
      <title>Clean Architecture: Why I Stopped Injecting DbContext Directly</title>
      <dc:creator>Javid KoluRazhan</dc:creator>
      <pubDate>Fri, 16 May 2025 11:36:20 +0000</pubDate>
      <link>https://dev.to/razhan1994/clean-architecture-why-i-stopped-injecting-dbcontext-directly-1lc5</link>
      <guid>https://dev.to/razhan1994/clean-architecture-why-i-stopped-injecting-dbcontext-directly-1lc5</guid>
      <description>&lt;p&gt;In my early days with ASP.NET Core, I often injected DbContext directly into controllers or services. It worked — but over time, things got messy: hard-to-test code, tight coupling, and business logic leaking into the infrastructure.&lt;/p&gt;

&lt;p&gt;Here’s what I do now:&lt;br&gt;
I use the &lt;strong&gt;Repository Pattern&lt;/strong&gt; + &lt;strong&gt;Unit of Work&lt;/strong&gt; to abstract away the data access logic. My services talk to interfaces like IOrderRepository, not DbContext.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh6epa3ua96qpmac8usqq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh6epa3ua96qpmac8usqq.png" alt="Image description" width="800" height="1200"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public interface IOrderRepository
{
    Task&amp;lt;Order&amp;gt; GetByIdAsync(Guid id);
    void Add(Order order);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Benefits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Easier unit testing (mocking repositories)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Clear separation of concerns&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Domain logic is not mixed with EF-specific code&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Tip:&lt;br&gt;
If you're working on a medium-to-large project, try isolating EF Core behind interfaces. It’s a small change that pays off big time.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>beginners</category>
      <category>dotnet</category>
    </item>
  </channel>
</rss>
