<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Arda Senbaklavaci on Medium]]></title>
        <description><![CDATA[Stories by Arda Senbaklavaci on Medium]]></description>
        <link>https://medium.com/@ardasenbakkavaci?source=rss-fbc775c265dd------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*VXXZgKsyIaaAkTeP</url>
            <title>Stories by Arda Senbaklavaci on Medium</title>
            <link>https://medium.com/@ardasenbakkavaci?source=rss-fbc775c265dd------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 31 May 2026 18:42:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ardasenbakkavaci/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com" rel="hub"/>
        <item>
            <title><![CDATA[Is DeepCool AK400 Enough For R5 7600X?]]></title>
            <link>https://medium.com/@ardasenbakkavaci/is-ak400-enough-for-r5-7600x-84769fac8dbd?source=rss-fbc775c265dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/84769fac8dbd</guid>
            <category><![CDATA[deepcool]]></category>
            <category><![CDATA[7600x]]></category>
            <category><![CDATA[deepcool-ak400]]></category>
            <category><![CDATA[ak400]]></category>
            <category><![CDATA[amd-ryzen-5-7600x]]></category>
            <dc:creator><![CDATA[Arda Senbaklavaci]]></dc:creator>
            <pubDate>Mon, 02 Dec 2024 11:10:51 GMT</pubDate>
            <atom:updated>2024-12-08T22:50:45.031Z</atom:updated>
            <content:encoded><![CDATA[<p>I decided to upgrade to a budget Ryzen 7000 System… And I found out that Ryzen5 7600x with Asus Tuf B650M-PLUS Motherboard and 32 Gigs Gskill Ram will be the budget match of my system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/0*ROtWX_hg0XMmORER.jpg" /></figure><p>The <strong>AMD Ryzen 5 7600X</strong> is a 6-core, 12-thread processor based on the Zen 4 architecture, with a base clock of 4.7 GHz and a boost clock up to 5.3 GHz. It has a TDP of <strong>105W</strong>, supports DDR5 memory, and offers PCIe 5.0 compatibility, making it a strong mid-range option for gaming and productivity in modern systems.</p><p>So now on I needed a budget cooler to handle my 7600X which is offically 105W TDP. Done research and decided to have AK400 Which was 45USD in my country. AK620 and AG620 had price of 50–55USD which was normally a better choice but it was out of stock in my country… AIO’s were at good price but I didnt wanted to have Liquid Cooler because of problems happening with Pump (Noises, Malfunctions…) Even some China 240mm AIO’s were almost same price with AK400…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IrxH8YgjDMSlE3IY.jpg" /></figure><p>The DeepCool AK400 comes well-packaged, with a clean, minimalistic box design that reflects its aesthetic. Inside, you’ll find the cooler, mounting hardware for both Intel and AMD sockets, a user manual, and a single 120mm PWM fan. The all-black design with subtle branding makes it suitable for various build themes, whether you’re going for stealth or a pop of color with RGB elsewhere in your setup.</p><ul><li>Four heat pipes for efficient heat transfer.</li><li>Compatibility with most modern sockets, including Intel LGA1700 and AMD AM5.</li><li>220W Official TDP Rate</li></ul><p>AK400 Zero Dark Plus comes with extra fan. But it is only for airflow, you may not notice extra cooling at temperatures. AG400 is for users who doesnt want to pay extra for aestethics…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/394/0*zjB-hI7fF13Yi6v5.jpg" /></figure><h3>AK400 And R5 7600X : BENCHMARKS</h3><p>First of all, I want to show the airflow confugiration. As Case for my system, I have Darkflash DK431 Case, with standard of 3 fans in front and 1 exhaust fan at exit… But I added 2 extra inputs from bottom, and 2 extra exhaust fan at top.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*viKDkJQx7p4dCCtq" /><figcaption>DK431 E-Atx Case</figcaption></figure><p>R5 7600X have performed well in Cinebench R23 All Core Cpu Benchmark, result varying from 14500 to 15100…</p><p>Within Default Bios settings of R5 7600X (With Asus TUF B650M-PLUS Wifi Motherboard). R23 Performed about 14573 points in Multicore, with tepmerature of 92C… (Amd Officially announced that Ryzen 7000’s have operating temperature up to 95C). AK400 Have let 7600x to work at TDP Rate of 119watts which means even it can handle standart boost frequency of 7600X… Normally 7600X Has TDP Of 105Watt…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/376/1*DzaMVjq2krLryvgkn5RGUA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/529/1*E3ZN3OHoQueYJJ_eXhszfQ.png" /><figcaption>Temperatures in Hwinfo</figcaption></figure><p>So now let’s optimize our 7600X settings at BIOS, to decrease the temperature and have better results at Benchmark…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bCA69gJF8Z381febiS3-OQ.png" /></figure><p>Let’s have curve optimizer at negative 13… You can go through until your system crash. In this test I made this value -13. My system performed well for 3 months with value -19. Increase value when you have BSOD…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EaGTPGVmpujS1SvLjUbE3Q.png" /></figure><p>And thermal throttle limit at 88C. (You can enter your value from 80 to 90C)…</p><p>Now the cpu curve voltage decreased -13mv and thermal limit is set to 88C which make system to have thermal throttle at lower level of temperature.</p><p>PBO Curve Tune is recommended for users who even prefer High Range 360mm AIO or even custom loop cooling… You will have better performance with less voltage, shortly you are tweaking your cpu for better performance without any cost…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/592/1*SV9_OMwpTkjEnZlu778C5g.png" /></figure><p>Now System has achieved 15113 points at Cinebench R23 With temperature of 88C max…</p><p>AK400 Has about 30–32C in idle operations… And 40–42C in package temp of CPU…</p><h3>Test System:</h3><p>Here is my complete System I used at this benchmark…</p><p><strong>CPU:</strong> Amd Ryzen 5 7600X</p><p><strong>Motherboard: </strong>Asus TUF B650M-Plus Wifi</p><p><strong>Ram:</strong> Gskill Flare X5 32GB DDR5 6000Mhz (2x16GB) 32CL Ram</p><p><strong>GPU:</strong> Zotac Twin Edge RTX 3060Ti OC 8GB GDDR5</p><p><strong>Cooler:</strong> DeepCool AK400</p><p><strong>NVME SSD: </strong>Crucial P3 1TB Nvme 3500mb/s RW</p><p><strong>SATA SSD: </strong>Kioxia Exceria 960GB</p><p><strong>HDD: </strong>WDC WD20EZRX-00D8PB0 : 2000,3 GB</p><p><strong>Case:</strong> DK431 DarkFlash E-ATX Case</p><p><strong>PSU: </strong>FSP Hyper S 700W Silver 85+ Single Rail</p><h3>AK400 And R5 7600X : Game Temperatures</h3><p>Here are my videos of R5 7600X with AK400, Game Temperatures:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FLaq40VhsORw%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DLaq40VhsORw&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FLaq40VhsORw%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/dd43dec81aa37d900400d4c89af6a2dd/href">https://medium.com/media/dd43dec81aa37d900400d4c89af6a2dd/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F3mm173pWhaI%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D3mm173pWhaI&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F3mm173pWhaI%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/26f033f98863a2af9d952cf9e92709bc/href">https://medium.com/media/26f033f98863a2af9d952cf9e92709bc/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FKsSCcf9xsS4%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DKsSCcf9xsS4&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FKsSCcf9xsS4%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/734fcd744cc08b196842492fa158ba82/href">https://medium.com/media/734fcd744cc08b196842492fa158ba82/href</a></iframe><h3>Conclusion:</h3><p>The <strong>DeepCool AK400</strong> is a standout budget air cooler that delivers a compelling mix of performance, simplicity, and affordability. It excels in providing efficient cooling for mid-range CPUs while maintaining a compact footprint and quiet operation. The minimalist design, with variants like the Zero Dark and WH models, ensures it fits seamlessly into various build aesthetics, whether you’re going for a stealthy blackout or a bright white theme.</p><p>While it lacks premium features like RGB lighting or extensive overclocking support, its performance-to-price ratio makes it an excellent choice for budget-conscious users or those looking to upgrade from stock coolers. The AK400 proves you don’t need to overspend to keep your system cool and reliable. For its price point, it punches well above its weight, making it a top contender in the budget air cooling market.</p><p>Shortly, the DeepCool AK400 performed completely fine in Amd Ryzen 5 7600x Cpu… It will also handle other mid to high range AMD Ryzen 7000 and 9000 Cpu’s like R7 7700,R7 7700x… Also you can look for this budget cooler for Amd Ryzen 5000 AM4 Processors, and similar Intel LGA 1200/1700 Core Cpu’s which will not exceed 120–130Watts TDP…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/1*tYVCDpQiLvj9mpKQgzCFEQ.png" /><figcaption>Other AK400 Variants</figcaption></figure><h3>Alternative Coolers:</h3><p>First of all, if you have a few bucks more budget, you can go through the dual-tower AK620 Cooler with dual fan… It may handle more TDP Within a few bucks more, with similar looking…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/447/1*VPbDP858LwkM76xscyCFOw.png" /></figure><p><strong>Noctua NH-U12S Redux</strong></p><ul><li>Compact single-tower design.</li><li>Reliable cooling and quiet operation.</li><li>Great for smaller cases.</li></ul><p><strong>be quiet! Dark Rock 4</strong></p><ul><li>Stylish, high-performance cooler with minimal noise.</li><li>Compact enough for most builds.</li></ul><p><strong>Cooler Master Hyper 212 Black Edition</strong></p><ul><li>Budget-friendly option with solid performance.</li><li>Sleek black design and easy installation.</li></ul><p><strong>And other Quality 240 or 360mm AIO’S…</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=84769fac8dbd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Consuming NodeJS Backend API In Android (Kotlin)]]></title>
            <link>https://medium.com/@ardasenbakkavaci/consuming-nodejs-backend-api-in-android-kotlin-3d93f43aa4ac?source=rss-fbc775c265dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/3d93f43aa4ac</guid>
            <dc:creator><![CDATA[Arda Senbaklavaci]]></dc:creator>
            <pubDate>Mon, 07 Oct 2024 18:28:58 GMT</pubDate>
            <atom:updated>2024-10-07T18:28:58.579Z</atom:updated>
            <content:encoded><![CDATA[<p>In this tutorial, I’ll walk you through connecting an Android app to a Node.js backend API using Retrofit. We’ll set up a simple API that allows you to fetch and display user data from an SQL database in your Android app. By the end, you’ll be able to send requests and show data in a RecyclerView from an external backend service!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/447/1*yYlWtysdZ2xZ4ANfxcqSrw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/332/1*ktDtUMGtvzjx5qVJpYtp5Q.png" /></figure><p><strong>Before Start:</strong></p><p>Set up your NodeJs Backend and make sure it is accessible from your local-host... Here is the link for NodeJs Sample Backend project ready.</p><ul><li><a href="https://medium.com/@ardasenbakkavaci/react-backend-sql-tutorial-9f8f8103d75f">React Backend SQL Tutorial</a></li><li><a href="https://github.com/ardasenbaklavaci/React-SQL-Tutorial-Backend?source=post_page-----9f8f8103d75f--------------------------------">GitHub - ardasenbaklavaci/React-SQL-Tutorial-Backend: React SQL Tutorial Backend Side</a></li></ul><h3>Step 1: Set Up Retrofit in Your Android Project</h3><h3>1.1 Add Retrofit Dependencies</h3><p>In your Android project, add Retrofit and Gson dependencies to your build.gradle (app-level):</p><pre>dependencies {<br>    implementation &#39;com.squareup.retrofit2:retrofit:2.9.0&#39;<br>    implementation &#39;com.squareup.retrofit2:converter-gson:2.9.0&#39;<br>}</pre><p>Sync your project to ensure the dependencies are downloaded and available.</p><h3>1.2 Create the Retrofit Client</h3><p>Next, create a Kotlin class called RetrofitClient. This class will help us create a singleton instance of Retrofit and provide access to the backend API.</p><pre>object RetrofitClient {<br>    private const val BASE_URL = &quot;http://10.0.2.2:3001/&quot; // 10.0.2.2 for localhost access in Android Emulator<br><br>    val instance: Retrofit by lazy {<br>        Retrofit.Builder()<br>            .baseUrl(BASE_URL)<br>            .addConverterFactory(GsonConverterFactory.create())<br>            .build()<br>    }<br>}</pre><p>Here, BASE_URL is the URL of your backend. If you’re running a local backend, use 10.0.2.2 to route requests from your Android emulator to your localhost.</p><h3>Step 2: Define API Endpoints Using Retrofit</h3><p>In this step, you will create an interface that defines the backend API endpoints.</p><h3>2.1 Create ApiService Interface</h3><p>In your ApiService interface, define methods to interact with the API. These methods correspond to the GET and POST endpoints of your Node.js API.</p><pre>data class User(<br>    @SerializedName(&quot;Id&quot;) val id: Int,<br>    @SerializedName(&quot;Name&quot;) val name: String,<br>    @SerializedName(&quot;Email&quot;) val email: String<br>)<br><br>interface ApiService {<br>    @GET(&quot;users&quot;)<br>    fun getUsers(): Call&lt;List&lt;User&gt;&gt;<br><br>    @POST(&quot;users&quot;)<br>    @FormUrlEncoded<br>    fun addUser(<br>        @Field(&quot;Id&quot;) id: Int,<br>        @Field(&quot;Name&quot;) name: String,<br>        @Field(&quot;Email&quot;) email: String<br>    ): Call&lt;User&gt;<br>}</pre><p>The @SerializedName annotations ensure the JSON fields match the model names in Kotlin.</p><h3>Step 3: Fetch Data Using Retrofit in MainActivity</h3><p>Now, we’ll implement the logic in MainActivity.kt to make the API calls and display the results.</p><h3>3.1 Set Up MainActivity</h3><p>In MainActivity.kt, we will fetch and display the list of users from the API. Later, we can add functionality to post new users.</p><pre>class MainActivity : AppCompatActivity() {<br><br>    override fun onCreate(savedInstanceState: Bundle?) {<br>        super.onCreate(savedInstanceState)<br>        setContentView(R.layout.activity_main)<br><br>        fetchUsers() // Fetch users on activity start<br>    }<br><br>    private fun fetchUsers() {<br>        val api = RetrofitClient.instance.create(ApiService::class.java)<br><br>        api.getUsers().enqueue(object : Callback&lt;List&lt;User&gt;&gt; {<br>            override fun onResponse(call: Call&lt;List&lt;User&gt;&gt;, response: Response&lt;List&lt;User&gt;&gt;) {<br>                if (response.isSuccessful) {<br>                    val userList = response.body()<br>                    userList?.let { displayUsers(it) }<br>                }<br>            }<br><br>            override fun onFailure(call: Call&lt;List&lt;User&gt;&gt;, t: Throwable) {<br>                Log.e(&quot;MainActivity&quot;, &quot;Error fetching users&quot;, t)<br>            }<br>        })<br>    }<br><br>    private fun displayUsers(users: List&lt;User&gt;) {<br>        // Code to display users in a RecyclerView goes here<br>    }<br>}</pre><p>The fetchUsers() function makes a call to getUsers() from the ApiService. On success, we display the list of users in the UI.</p><h3>3.2 Handle Network Security Config</h3><p>To allow communication with your local backend, add a network_security_config.xml file in res/xml/.</p><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;<br>&lt;network-security-config&gt;<br>    &lt;domain-config cleartextTrafficPermitted=&quot;true&quot;&gt;<br>        &lt;domain includeSubdomains=&quot;true&quot;&gt;localhost&lt;/domain&gt;<br>    &lt;/domain-config&gt;<br>&lt;/network-security-config&gt;</pre><p>Reference this in the AndroidManifest.xml:</p><pre>&lt;application<br>    android:networkSecurityConfig=&quot;@xml/network_security_config&quot;<br>    ... &gt;<br>&lt;/application&gt;</pre><p>This allows the Android emulator to communicate with your backend using HTTP.</p><h3>Step 4: Display Data in RecyclerView</h3><p>Now, we will display the fetched users using a RecyclerView. In activity_main.xml, set up a simple layout:</p><pre>&lt;LinearLayout<br>    xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;<br>    android:layout_width=&quot;match_parent&quot;<br>    android:layout_height=&quot;match_parent&quot;<br>    android:orientation=&quot;vertical&quot;&gt;<br><br>    &lt;RecyclerView<br>        android:id=&quot;@+id/recyclerView&quot;<br>        android:layout_width=&quot;match_parent&quot;<br>        android:layout_height=&quot;match_parent&quot;<br>        android:layout_margin=&quot;16dp&quot;/&gt;<br>&lt;/LinearLayout&gt;</pre><p>In MainActivity, add the logic to bind the data to a RecyclerView. Create an Adapter to display the list of users.</p><pre>class UserAdapter(private val userList: List&lt;User&gt;) : RecyclerView.Adapter&lt;UserAdapter.UserViewHolder&gt;() {<br><br>    class UserViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {<br>        val nameTextView: TextView = itemView.findViewById(R.id.nameTextView)<br>        val emailTextView: TextView = itemView.findViewById(R.id.emailTextView)<br>    }<br><br>    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): UserViewHolder {<br>        val view = LayoutInflater.from(parent.context).inflate(R.layout.user_item, parent, false)<br>        return UserViewHolder(view)<br>    }<br><br>    override fun onBindViewHolder(holder: UserViewHolder, position: Int) {<br>        val user = userList[position]<br>        holder.nameTextView.text = user.name<br>        holder.emailTextView.text = user.email<br>    }<br><br>    override fun getItemCount(): Int = userList.size<br>}</pre><p>In MainActivity, bind the RecyclerView with the UserAdapter:</p><pre>private fun displayUsers(users: List&lt;User&gt;) {<br>    val recyclerView = findViewById&lt;RecyclerView&gt;(R.id.recyclerView)<br>    recyclerView.layoutManager = LinearLayoutManager(this)<br>    recyclerView.adapter = UserAdapter(users)<br>}</pre><p>Now, when you run the app, you should be able to see the user data fetched from the backend displayed in a RecyclerView!</p><p><strong>Running App:</strong></p><p>First of all, run your Node Js Backend as at the ending of tutorial and make sure it is listening at your localhost:3001 . Go to <a href="http://localhost:3001/users">http://localhost:3001/users</a> in browser to make sure you recieve response from backend.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/572/1*IRehBQB8yLgEzfdrH6KDeA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/362/1*aCwKyzJ-g-lVe-l4Vpx3RQ.png" /></figure><p>Now run the kotlin app and you will see:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/206/1*sjZll36AYnlxVQFRG93fiw.png" /></figure><p>So, the app recieved data from NodeJs Backend…</p><p>By following these steps, you’ve created a simple yet powerful Android application that communicates with an external API. You can extend this by adding more functionality such as creating, updating, or deleting users.</p><p>Github:</p><p><a href="https://github.com/ardasenbaklavaci/Android-NodeJs-Api-Tutorial-Retrofit">GitHub - ardasenbaklavaci/Android-NodeJs-Api-Tutorial-Retrofit: Tutorial to consume NodeJs backend api in Android Kotlin</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3d93f43aa4ac" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React Backend SQL Tutorial]]></title>
            <link>https://medium.com/@ardasenbakkavaci/react-backend-sql-tutorial-9f8f8103d75f?source=rss-fbc775c265dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/9f8f8103d75f</guid>
            <dc:creator><![CDATA[Arda Senbaklavaci]]></dc:creator>
            <pubDate>Mon, 16 Sep 2024 15:33:07 GMT</pubDate>
            <atom:updated>2024-09-16T19:47:31.710Z</atom:updated>
            <content:encoded><![CDATA[<p>In this tutorial, we’ll walk through creating a simple full-stack web application using <strong>React</strong> for the frontend, <strong>Node.js</strong> and <strong>Express</strong> for the backend, and <strong>MySQL</strong> as the database. By the end of this guide, you’ll have a functional app that allows you to interact with a MySQL database — fetching and inserting data — using RESTful API endpoints.</p><p>This tutorial is perfect for developers looking to bridge the gap between frontend and backend technologies, while also learning how to connect to relational databases like MySQL.</p><ul><li>Setting up a MySQL database and table.</li><li>Building the backend API using <strong>Node.js</strong> and <strong>Express</strong>.</li><li>Connecting the backend to a <strong>React</strong> frontend.</li><li>Making HTTP requests with <strong>Axios</strong> to interact with the MySQL database.</li><li>Handling both GET and POST requests for fetching and adding data.</li></ul><p>So lets start…</p><p>First of all, lets create our sample database for this project in MySQL and insert sample data… MySQL suits best for this project because you will not have to mess with TCP/IP Settings (as you need to do in MSSQL)…</p><pre>create database demo;<br><br>CREATE TABLE Users (<br>    Id INT AUTO_INCREMENT PRIMARY KEY,<br>    Name NVARCHAR(100) NOT NULL,<br>    Email NVARCHAR(100) NOT NULL<br>);<br>INSERT INTO Users (Name, Email) VALUES (&#39;John Doe&#39;, &#39;john.doe@example.com&#39;);<br>INSERT INTO Users (Name, Email) VALUES (&#39;Jane Smith&#39;, &#39;jane.smith@example.com&#39;);<br>INSERT INTO Users (Name, Email) VALUES (&#39;Alice Johnson&#39;, &#39;alice.johnson@example.com&#39;);</pre><h3>Prerequisites</h3><ol><li><strong>Node.js and npm</strong>: Install from <a href="https://nodejs.org/">Node.js official website</a>. Node js is required for backend side…</li><li><strong>SQL Database</strong>: Install MySQL, PostgreSQL, or any SQL database of your choice. We will use MySQL in this tutorial…</li><li><strong>Basic understanding</strong>: Familiarity with JavaScript, React, SQL, and basic backend development.</li></ol><h3>1:Set Up Backend</h3><ol><li>Create a new backend project:</li></ol><pre>mkdir react-sql-backend<br>cd react-sql-backend<br>npm init -y</pre><p>2. Install necessary packages:</p><pre>npm install express mysql2 cors body-parser</pre><ul><li>express: A web framework for Node.js.</li><li>mysql2: A MySQL client for Node.js.</li><li>cors: Middleware to enable Cross-Origin Resource Sharing.</li><li>body-parser: Middleware to parse incoming request bodies.</li></ul><p>3. Create an index.js file for the backend:</p><pre>const express = require(&#39;express&#39;);<br>const mysql = require(&#39;mysql2&#39;);<br>const cors = require(&#39;cors&#39;);<br>const bodyParser = require(&#39;body-parser&#39;);<br><br>const app = express();<br>app.use(cors());<br>app.use(bodyParser.json());<br><br>// MySQL Database Connection<br>const db = mysql.createConnection({<br>  host: &#39;localhost&#39;,<br>  user: &#39;root&#39;,<br>  password: &#39;password&#39;,<br>  database: &#39;your_database_name&#39;<br>});<br><br>db.connect((err) =&gt; {<br>  if (err) {<br>    console.error(&#39;Database connection failed:&#39;, err.stack);<br>    return;<br>  }<br>  console.log(&#39;Connected to MySQL database.&#39;);<br>});<br><br>// API Endpoint Example: Fetch Users<br>app.get(&#39;/users&#39;, (req, res) =&gt; {<br>  db.query(&#39;SELECT * FROM users&#39;, (err, results) =&gt; {<br>    if (err) {<br>      res.status(500).send(err);<br>    } else {<br>      res.json(results);<br>    }<br>  });<br>});<br><br>// API Endpoint Example: Add a New User<br>app.post(&#39;/users&#39;, (req, res) =&gt; {<br>  const { name, email } = req.body;<br>  db.query(&#39;INSERT INTO users (name, email) VALUES (?, ?)&#39;, [name, email], (err, results) =&gt; {<br>    if (err) {<br>      res.status(500).send(err);<br>    } else {<br>      res.json({ id: results.insertId, name, email });<br>    }<br>  });<br>});<br><br>const PORT = 3001;<br>app.listen(PORT, () =&gt; {<br>  console.log(`Server running on port ${PORT}`);<br>});</pre><p>Dont forget to change user, password and database for your project…</p><p>4. Run the backend server:</p><pre>node index.js</pre><p>When you recieved the log ‘Connected to MySQL database.’ at Terminal Console, this means your backend is working… Also you can debug your errors here…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/330/1*8eU5Sy8Uh4dczvfvQR6tfg.png" /><figcaption>Backend is working on port /3001</figcaption></figure><p>So now backend pipe is streaming at <a href="http://localhost:3001">http://localhost:3001</a> . Do not turn off this terminal since it streams backend to your localhost…</p><h3>Step 2: Set Up the React Frontend</h3><ol><li>Create a new React project:</li></ol><pre>npx create-react-app react-sql-frontend<br>cd react-sql-frontend</pre><p>2. <strong>Install Axios</strong> for making HTTP requests:</p><pre>npm install axios</pre><p>3. Create a component to fetch and display data:</p><p>Create a new file Users.js in the src folder:</p><pre>import React, { useEffect, useState } from &#39;react&#39;;<br>import axios from &#39;axios&#39;;<br><br>const Users = () =&gt; {<br>  const [users, setUsers] = useState([]);<br><br>  useEffect(() =&gt; {<br>    axios.get(&#39;http://localhost:3001/users&#39;)<br>      .then(response =&gt; {<br>        setUsers(response.data);<br>      })<br>      .catch(error =&gt; {<br>        console.error(&#39;There was an error fetching the users!&#39;, error);<br>      });<br>  }, []);<br><br>  return (<br>    &lt;div&gt;<br>      &lt;h1&gt;Users List&lt;/h1&gt;<br>      &lt;ul&gt;<br>        {users.map(user =&gt; (<br>          &lt;li key={user.id}&gt;{user.name} - {user.email}&lt;/li&gt;<br>        ))}<br>      &lt;/ul&gt;<br>    &lt;/div&gt;<br>  );<br>};<br><br>export default Users;</pre><p><strong>4. </strong>Use the Users component in App.js:</p><pre>import React from &#39;react&#39;;<br>import Users from &#39;./Users&#39;;<br><br>function App() {<br>  return (<br>    &lt;div className=&quot;App&quot;&gt;<br>      &lt;Users /&gt;<br>    &lt;/div&gt;<br>  );<br>}<br><br>export default App;</pre><p><strong>5. </strong>Run the React application:</p><pre>npm start</pre><h3>Step 3: Testing the Application</h3><ul><li>Open your browser and navigate to <a href="http://localhost:3000.">http://localhost:3000.</a></li><li>You should see a list of users fetched from your SQL database.</li></ul><h3>Step 4: Adding New Users</h3><p>To add a form to insert new users:</p><ol><li>Update the Users.js component:</li></ol><pre>import React, { useEffect, useState } from &#39;react&#39;;<br>import axios from &#39;axios&#39;;<br><br>const Users = () =&gt; {<br>  const [users, setUsers] = useState([]);<br>  const [name, setName] = useState(&#39;&#39;);<br>  const [email, setEmail] = useState(&#39;&#39;);<br><br>  useEffect(() =&gt; {<br>    fetchUsers();<br>  }, []);<br><br>  const fetchUsers = () =&gt; {<br>    axios.get(&#39;http://localhost:3001/users&#39;)<br>      .then(response =&gt; {<br>        setUsers(response.data);<br>      })<br>      .catch(error =&gt; {<br>        console.error(&#39;There was an error fetching the users!&#39;, error);<br>      });<br>  };<br><br>  const handleAddUser = () =&gt; {<br>    axios.post(&#39;http://localhost:3001/users&#39;, { name, email })<br>      .then(response =&gt; {<br>        setUsers([...users, response.data]);<br>        setName(&#39;&#39;);<br>        setEmail(&#39;&#39;);<br>      })<br>      .catch(error =&gt; {<br>        console.error(&#39;There was an error adding the user!&#39;, error);<br>      });<br>  };<br><br>  return (<br>    &lt;div&gt;<br>      &lt;h1&gt;Users List&lt;/h1&gt;<br>      &lt;ul&gt;<br>        {users.map(user =&gt; (<br>          &lt;li key={user.id}&gt;{user.name} - {user.email}&lt;/li&gt;<br>        ))}<br>      &lt;/ul&gt;<br><br>      &lt;h2&gt;Add New User&lt;/h2&gt;<br>      &lt;input<br>        type=&quot;text&quot;<br>        placeholder=&quot;Name&quot;<br>        value={name}<br>        onChange={e =&gt; setName(e.target.value)}<br>      /&gt;<br>      &lt;input<br>        type=&quot;email&quot;<br>        placeholder=&quot;Email&quot;<br>        value={email}<br>        onChange={e =&gt; setEmail(e.target.value)}<br>      /&gt;<br>      &lt;button onClick={handleAddUser}&gt;Add User&lt;/button&gt;<br>    &lt;/div&gt;<br>  );<br>};<br><br>export default Users;</pre><h3>Enhancements</h3><ul><li><strong>Validation</strong>: Add client-side and server-side validation for better data handling.</li><li><strong>Error Handling</strong>: Improve error handling for network errors or database issues.</li><li><strong>State Management</strong>: Consider using a state management library like Redux for larger applications.</li></ul><p>After starting the app (frontend side), you will see the names and email adresses returned from SQL (Backend) which is GET Method.</p><p>Also you can post new name and email couple with POST Method called from Backend…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/430/1*9v-gLCrVp5XKNZX47IqSLw.png" /><figcaption>User List is GET Method, Add a New User is Post Method</figcaption></figure><p><strong>Github Links:</strong></p><p>Backend:</p><p><a href="https://github.com/ardasenbaklavaci/React-SQL-Tutorial-Backend">GitHub - ardasenbaklavaci/React-SQL-Tutorial-Backend: React SQL Tutorial Backend Side</a></p><p>Frontend:</p><p><a href="https://github.com/ardasenbaklavaci/React-SQL-Tutorial-Frontend">GitHub - ardasenbaklavaci/React-SQL-Tutorial-Frontend: React SQL Tutorial Frontend Side</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9f8f8103d75f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[.Net Core API Reverse Engineering With EfCore Power Tools]]></title>
            <link>https://medium.com/@ardasenbakkavaci/net-core-api-reverse-engineering-with-efcore-power-tools-1c2d597cdf73?source=rss-fbc775c265dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/1c2d597cdf73</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[dot-net-core]]></category>
            <category><![CDATA[aspnetcore]]></category>
            <category><![CDATA[web-developement]]></category>
            <dc:creator><![CDATA[Arda Senbaklavaci]]></dc:creator>
            <pubDate>Thu, 27 Jun 2024 07:37:19 GMT</pubDate>
            <atom:updated>2024-06-27T07:37:19.660Z</atom:updated>
            <content:encoded><![CDATA[<p>Welcome to this tutorial on reverse engineering a .NET Core API from an SQL database using EF Core Power Tools. EF Core Power Tools is a powerful Visual Studio extension that simplifies the creation of Entity Framework Core (EF Core) models from existing databases. This toolset empowers developers to quickly scaffold a fully-functional API that mirrors their database schema.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/291/1*IRyFVwND3ndecYxgKsCy9A.png" /></figure><p>Shortly, EfCorePowerTools let you implement API directly from SQL Server and consume it from .NET Core…</p><p>To successfully reverse engineer a .NET Core API from an SQL database using EF Core Power Tools, you’ll need to install several NuGet packages. These packages facilitate the development of the API and enable smooth interactions with your SQL database.</p><p>Required NuGet Packages:</p><h3>1. Microsoft.EntityFrameworkCore</h3><p><strong>Purpose</strong>: This is the core package for EF Core, providing the essential functionalities for ORM (Object-Relational Mapping).</p><p>dotnet add package Microsoft.EntityFrameworkCore</p><h3>2. Microsoft.EntityFrameworkCore.SqlServer</h3><p><strong>Purpose</strong>: This package is required to use SQL Server as your database provider with EF Core.</p><p>dotnet add package Microsoft.EntityFrameworkCore.SqlServer</p><p><em>Note</em>: If you’re using a different database, you should install the corresponding provider package, such as:</p><ul><li>Microsoft.EntityFrameworkCore.Sqlite for SQLite</li><li>Npgsql.EntityFrameworkCore.PostgreSQL for PostgreSQL</li><li>Pomelo.EntityFrameworkCore.MySql for MySQL</li></ul><h3>3. Microsoft.EntityFrameworkCore.Design</h3><p><strong>Purpose</strong>: This package provides tools for EF Core design-time services like scaffolding and migrations. It is essential for reverse engineering and generating EF Core models from an existing database.</p><p>dotnet add package Microsoft.EntityFrameworkCore.Design</p><h3>4. Microsoft.EntityFrameworkCore.Tools</h3><p><strong>Purpose</strong>: Provides command-line tools for EF Core operations, such as database migrations and reverse engineering. These tools can be used in Visual Studio’s Package Manager Console or via the .NET CLI.</p><p>dotnet add package Microsoft.EntityFrameworkCore.Tools</p><h3>5. Microsoft.Extensions.Logging.Console</h3><p><strong>Purpose</strong>: This package enables console logging for EF Core operations, which is helpful for debugging and monitoring SQL queries and other activities.</p><p>dotnet add package Microsoft.Extensions.Logging.Console</p><h3>Summary of Installation Commands</h3><p>For convenience, here’s a summary of the CLI commands to install the necessary packages:</p><p>dotnet add package Microsoft.EntityFrameworkCore dotnet add package Microsoft.EntityFrameworkCore.SqlServer dotnet add package Microsoft.EntityFrameworkCore.Design dotnet add package Microsoft.EntityFrameworkCore.Tools dotnet add package Microsoft.Extensions.Logging.Console</p><p>Start:</p><p>After opening the project, we will have this project solution explorer hierarchy… We will have our sample class for this project, WeatherForecast.cs class. And a sample Controller WeatherForecastController.cs, lets keep theese for reference…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/445/1*71dDgYLjHioZTCqZPtQblw.png" /></figure><p>When we launch this project, we will have the sample WeatherForecast API Implemented… Running at Swagger UI Interface.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/587/1*IVaSfXv-mU4b8CDtkgP8cw.png" /></figure><p>And lets execute this…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/607/1*U8zPY6xeXV_bEC__ZI0RMQ.png" /></figure><p>We can see our GET operation returned all data… With status of 200 (Succesfull). This number indicates the result status for debugging.</p><p>After making sure Swagger UI is working with sample data of project, now Lets create our sample database table and insert sample data’s… Here is query for our sample database, we will use MSSQL…</p><pre>-- Create the Books table<br>CREATE TABLE Books (<br>    Id INT PRIMARY KEY IDENTITY(1,1),<br>    Title VARCHAR(255) NOT NULL,<br>    Author VARCHAR(255) NOT NULL,<br>    PublishedYear INT NOT NULL,<br>    Genre VARCHAR(100),<br>    Price DECIMAL(10, 2)<br>);<br><br>-- Insert sample data into the Books table<br>INSERT INTO Books (Title, Author, PublishedYear, Genre, Price) VALUES<br>(&#39;The Great Gatsby&#39;, &#39;F. Scott Fitzgerald&#39;, 1925, &#39;Classic&#39;, 10.99),<br>(&#39;To Kill a Mockingbird&#39;, &#39;Harper Lee&#39;, 1960, &#39;Classic&#39;, 7.99),<br>(&#39;1984&#39;, &#39;George Orwell&#39;, 1949, &#39;Dystopian&#39;, 8.99),<br>(&#39;Pride and Prejudice&#39;, &#39;Jane Austen&#39;, 1813, &#39;Romance&#39;, 5.99),<br>(&#39;The Catcher in the Rye&#39;, &#39;J.D. Salinger&#39;, 1951, &#39;Classic&#39;, 6.99),<br>(&#39;Moby Dick&#39;, &#39;Herman Melville&#39;, 1851, &#39;Adventure&#39;, 12.50),<br>(&#39;War and Peace&#39;, &#39;Leo Tolstoy&#39;, 1869, &#39;Historical&#39;, 14.99),<br>(&#39;The Hobbit&#39;, &#39;J.R.R. Tolkien&#39;, 1937, &#39;Fantasy&#39;, 11.99),<br>(&#39;The Road&#39;, &#39;Cormac McCarthy&#39;, 2006, &#39;Post-Apocalyptic&#39;, 9.99),<br>(&#39;The Da Vinci Code&#39;, &#39;Dan Brown&#39;, 2003, &#39;Thriller&#39;, 7.50);</pre><p>Now go to your appsettings.json… Add your connection string:</p><pre>{<br>  &quot;ConnectionStrings&quot;: {<br>    &quot;DefaultConnection&quot;: &quot;Server=your_server_name;Database=your_database_name;User Id=your_username;Password=your_password;&quot;<br>  },<br>  &quot;Logging&quot;: {<br>    &quot;LogLevel&quot;: {<br>      &quot;Default&quot;: &quot;Information&quot;,<br>      &quot;Microsoft.AspNetCore&quot;: &quot;Warning&quot;<br>    }<br>  },<br>  &quot;AllowedHosts&quot;: &quot;*&quot;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*ynxuHKIDZbHgWrFXDcbjsA.png" /></figure><p>Now right click on your project (Not Solution!!!) and extend EF Core Power Tools…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/288/1*NNQwBZb1L5kJARNUlHaj4w.png" /></figure><p>And select Reverse Engineer…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*gPNK0xXQmqTOROw6ZH32zA.png" /></figure><p>Now lets make connection with SQL Server to scaffold.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/294/1*vXX6OUr6iFGHIperOasrcA.png" /></figure><p>Click on Add… and select Add Database Connection…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/629/1*7DHJxqLEM1Q3NnMOV7D1wg.png" /></figure><p>Here you can gather your Machine’s SQL Servers… Right now my EfCore can not sniff local MS SQL Servers (have a look at TCP Connections etc…) so lets have custom connection with connection string…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/209/1*uy280g_OO899RoqKiPjhVw.png" /></figure><p>From VS SQL Server Object Explorer, select your database and get your Connection String. My Connection String worked with EFCore by getting theese parts:</p><pre>Data Source=DESKTOP-2ED7HUR;Initial Catalog=apiProj;Integrated Security=True;Encrypt=False;Trust Server Certificate=False;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*N9wZKlAxkfvwQDXf6yFl2A.png" /></figure><p>Name your SQL Server Connection String and hit OK.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*2DT5JtLaQETY-Y38X8Z_JQ.png" /></figure><p>Now select your Connection String and EF Core Version, and hit OK.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/505/1*t5SZ0DCtD70f1iOfaXDY5w.png" /></figure><p>Now you can see your database entities sniffed from your SQL Server… You can reverse engineer Tables, Stored Procedures (if available) to consume.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/509/1*tJ4GgmmwWJy0devqYovwvw.png" /></figure><p>Now you will create your DataContext to consume database… First of all it will create models from your database and then it will generate DataContext to consume your data, stored procedures…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/221/1*7nSzYRL0WhPj-pS271yF2w.png" /></figure><p>So we generated our Book Model from database directly, and apiProjContext (Datacontext class) to consume the database.</p><pre>// &lt;auto-generated&gt; This file has been auto generated by EF Core Power Tools. &lt;/auto-generated&gt;<br>#nullable disable<br>using System;<br>using System.Collections.Generic;<br><br>namespace WebApplication6.Models;<br><br>public partial class Book<br>{<br>    public int Id { get; set; }<br><br>    public string Title { get; set; }<br><br>    public string Author { get; set; }<br><br>    public int PublishedYear { get; set; }<br><br>    public string Genre { get; set; }<br><br>    public decimal? Price { get; set; }<br>}</pre><p>EFCore generated Book class from database…</p><pre>// &lt;auto-generated&gt; This file has been auto generated by EF Core Power Tools. &lt;/auto-generated&gt;<br>#nullable disable<br>using System;<br>using System.Collections.Generic;<br>using Microsoft.EntityFrameworkCore;<br><br>namespace WebApplication6.Models;<br><br>public partial class apiProjContext : DbContext<br>{<br>    public apiProjContext(DbContextOptions&lt;apiProjContext&gt; options)<br>        : base(options)<br>    {<br>    }<br><br>    public virtual DbSet&lt;Book&gt; Books { get; set; }<br><br>    protected override void OnModelCreating(ModelBuilder modelBuilder)<br>    {<br>        modelBuilder.Entity&lt;Book&gt;(entity =&gt;<br>        {<br>            entity.HasKey(e =&gt; e.Id).HasName(&quot;PK__Books__3214EC075694FD1D&quot;);<br><br>            entity.Property(e =&gt; e.Author)<br>                .IsRequired()<br>                .HasMaxLength(255)<br>                .IsUnicode(false);<br>            entity.Property(e =&gt; e.Genre)<br>                .HasMaxLength(100)<br>                .IsUnicode(false);<br>            entity.Property(e =&gt; e.Price).HasColumnType(&quot;decimal(10, 2)&quot;);<br>            entity.Property(e =&gt; e.Title)<br>                .IsRequired()<br>                .HasMaxLength(255)<br>                .IsUnicode(false);<br>        });<br><br>        OnModelCreatingPartial(modelBuilder);<br>    }<br><br>    partial void OnModelCreatingPartial(ModelBuilder modelBuilder);<br>}</pre><p>And our DataContext…</p><p>Now lets create our Controller class to directly consume our API from Swagger UI and Postman (Later…)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/639/1*VaWE1Qf4QHM5KeP7ALmjEw.png" /></figure><p>Click on Add -&gt; Controller…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/164/1*fs0YBuk1zYH-qX8zBawxtQ.png" /></figure><p>Select API insted of MVC…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/514/1*OaHoOeQJ8TvTAM2KJqMn4w.png" /></figure><p>And API Controller-Empty… Name it BookController.cs</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/415/1*LlFF1ozSBo6TDazm80VDeA.png" /></figure><p>So it created our Controller with ControllerBase…</p><pre>using WebApplication6.Models;</pre><p>Import your DbContext directory and type your DataContext…</p><pre>public class BookController : ControllerBase<br>{<br>    apiProjContext dbContext;<br>}</pre><p>Make your constructor…</p><pre>[Route(&quot;api/[controller]&quot;)]<br>[ApiController]<br>public class BookController : ControllerBase<br>{<br>    apiProjContext dbContext;<br><br>    BookController(apiProjContext _dbContext)<br>    {<br>        this.dbContext = _dbContext;<br>    }<br>}</pre><p>Now lets make our Get All books implementation.</p><pre>  // GET: api/Book<br>  [HttpGet]<br>  public async Task&lt;ActionResult&lt;IEnumerable&lt;Book&gt;&gt;&gt; GetBooks()<br>  {<br>      return await _context.Books.ToListAsync();<br>  }</pre><p>This will return List of all Books… By adding list’s where attribute, we can have get book by id Implementation…</p><pre>[HttpGet(&quot;{id}&quot;)]<br>public async Task&lt;ActionResult&lt;Book&gt;&gt; GetBook(int id)<br>{<br>    var book = await _context.Books<br>                             .Where(b =&gt; b.Id == id)<br>                             .FirstOrDefaultAsync();<br><br>    if (book == null)<br>    {<br>        return NotFound();<br>    }<br><br>    return book;<br>}</pre><p>Also you can do this with:</p><pre>    [HttpGet(&quot;{id}&quot;)]<br>    public async Task&lt;ActionResult&lt;Book&gt;&gt; GetBook(int id)<br>    {<br>      var book = await _context.Books.FindAsync(id);<br><br>      if (book == null)<br>      {<br>        return NotFound();<br>      }<br><br>      return book;<br>    }</pre><p>Final code of the controller:</p><pre>using Microsoft.AspNetCore.Mvc;<br>using Microsoft.EntityFrameworkCore;<br>using System.Collections.Generic;<br>using System.Linq;<br>using System.Threading.Tasks;<br>using WebApplication6.Models;<br><br>namespace WebApplication6.Controllers<br>{<br>    [Route(&quot;api/[controller]&quot;)]<br>    [ApiController]<br>    public class BookController : ControllerBase<br>    {<br>        private readonly apiProjContext _context;<br><br>        // Constructor with the required DbContext parameter<br>        public BookController(apiProjContext context)<br>        {<br>            _context = context;<br>        }<br><br>        // GET: api/Book<br>        [HttpGet]<br>        public async Task&lt;ActionResult&lt;IEnumerable&lt;Book&gt;&gt;&gt; GetBooks()<br>        {<br>            return await _context.Books.ToListAsync();<br>        }<br><br>        // GET: api/Book/5<br>        [HttpGet(&quot;{id}&quot;)]<br>        public async Task&lt;ActionResult&lt;Book&gt;&gt; GetBook(int id)<br>        {<br>            var book = await _context.Books<br>                                     .Where(b =&gt; b.Id == id)<br>                                     .FirstOrDefaultAsync();<br><br>            if (book == null)<br>            {<br>                return NotFound();<br>            }<br><br>            return book;<br>        }<br>    }<br>}</pre><p>You can directly FindAsync with id…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/573/1*1FPiNw2F1S589Xooh6od9A.png" /></figure><p>If you get ModelBuilder error, Install: If this error exist…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j89WRovL3ITpXRpOVY4bNA.png" /></figure><p>Finally, in program.cs , add :</p><pre>var builder = WebApplication.CreateBuilder(args);<br><br>// Add services to the container.<br><br>// Configure the database context with SQL Server.<br>// Replace &quot;YourConnectionString&quot; with your actual connection string.<br>builder.Services.AddDbContext&lt;apiProjContext&gt;(options =&gt;<br>    options.UseSqlServer(builder.Configuration.GetConnectionString(&quot;DefaultConnection&quot;)));<br><br>// Add controllers service<br>builder.Services.AddControllers();</pre><p>To connect your SQL Connection String and DataContext to API.</p><p>Now launch the app:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/573/1*Qbb2dM8SjGuKtpvfonaUDA.png" /></figure><p>We got the API’s implemented at Controller.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/551/1*fNZQnA_PV4_Zkbfjbn9CMA.png" /></figure><p>And all books have returned to Interface…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1c2d597cdf73" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>