<?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 Emmanuel Gabriel on Medium]]></title>
        <description><![CDATA[Stories by Emmanuel Gabriel on Medium]]></description>
        <link>https://medium.com/@eghosagabriel?source=rss-e7e416df85f4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*3ZiDyeOYaWanTf6u.jpg</url>
            <title>Stories by Emmanuel Gabriel on Medium</title>
            <link>https://medium.com/@eghosagabriel?source=rss-e7e416df85f4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 22:36:53 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@eghosagabriel/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[Deploy your WebApp to Azure App Service through Local Git.]]></title>
            <link>https://medium.com/@eghosagabriel/deploy-your-webapp-to-azure-app-service-through-local-git-610e734f1ccd?source=rss-e7e416df85f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/610e734f1ccd</guid>
            <category><![CDATA[git]]></category>
            <category><![CDATA[app-service]]></category>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[deployment]]></category>
            <dc:creator><![CDATA[Emmanuel Gabriel]]></dc:creator>
            <pubDate>Sat, 04 Jun 2022 11:40:59 GMT</pubDate>
            <atom:updated>2022-06-18T18:00:19.061Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/659/1*e0Op6yiUIsISDVAQ8Moeow.png" /></figure><p><strong>Summary</strong>: In this tutorial, you will learn how to deploy your AspNet Mvc project to Azure App Service using our Local git.</p><p>Azure App Service is a platform as a service (PAAS) offering from Microsoft Azure that allows you to deploy Webapps, Mobile backends, and Restful APIs in any programming language of your choice without managing infrastructure.</p><blockquote><strong><em>The following illustration shows the deployed application.</em></strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-M1iBGO98jf0vMxh7LQyJA.png" /><figcaption>Deployed Application Illustration</figcaption></figure><blockquote><strong><em>Prerequisites</em></strong></blockquote><ul><li><a href="https://code.visualstudio.com/download">Visual Studio Code</a></li><li><a href="https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp">C# for Visual Studio Code (latest version)</a></li><li><a href="https://dotnet.microsoft.com/download/dotnet/6.0">.NET 6.0 SDK</a></li><li>Active Azure Account</li><li>Github Account</li></ul><p>We have the source code on this <a href="https://github.com/Virifortissimi/MyWebApp/tree/master">repository</a>. The source code is a basic AspNet MVC project so you could create one and use that for this tutorial.</p><blockquote><em>Excersice 1: Create Azure App Service on Azure</em></blockquote><p>Sign in to your Azure account at <a href="https://portal.azure.com/">https://portal.azure.com</a>. If you do not already have one, create an account to get a $200 Azure credit. You’ll have 30days to use this credit in addition to free resources available on the portal.</p><p>When signed in, Go to the <a href="https://portal.azure.com/#blade/HubsExtension/BrowseResource/resourceType/Microsoft.Web%2Fsites">App Service Deployment page</a>. then click on create.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/959/1*X1up7So3P_qeUFqmKFNwNQ.png" /><figcaption>App Service deployment page</figcaption></figure><p>On the Basics Tab. Select your preferred <strong>Subscription</strong>. For the <strong>Resource group</strong>, click on Create new and type in <em>MyWebAppRG. </em>In the <strong>Instance Details </strong>section, type in <em>mywebapp110 (or a different name) </em>for the Name which has to be unique as it would be used for the website URL upon completion. For <strong>Publish, </strong>leave as Code. For <strong>Runtime Stack, </strong>select <em>.Net 6 (LTS) </em>from the dropdown. You can also select whatever Runtime Stack you wish to use if you are deploying a different project. For <strong>Operating System, </strong>I would select <em>Linux. </em>For the <strong>Region, </strong>pick a location that is closest to you. At this point, your Basics tab should look exactly like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*l9UpRVE8LvIfdJXmfE7x4A.png" /><figcaption>App Service deployment basics tab</figcaption></figure><p>In the <strong>App Service Plan </strong>section, click Change size for <strong>Sku and size </strong>to select the preferred features and configuration for your deployed project. There are several specifications available as you can see below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/837/1*JUbD8y_JrqDJTkSaSX63Yg.png" /><figcaption>Azure App Service Spec picker</figcaption></figure><p>You can select whatever specification you prefer for your workload. However, since this is a test deployment. I would click on <em>Dev/Test, </em>then select either the <em>F1 or B1 pricing tiers </em>then Click Apply</p><p>Note that if you had picked any of the Specifications from the <strong>Production </strong>pricing tiers. You would have the option of enabling <strong>Zone redundancy</strong> which would allow your App service plan and the Apps in it to be zone redundant.</p><p>You can also configure Continuous Deployment through Github by going to the next tab Deployment. However, we want to deploy through our Local Git so click on <strong>Review + Create.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*hfWq_EzQJyDhe56W2Hth7g.png" /><figcaption>App Service Basics Tab</figcaption></figure><p>Review your configuration and click Create. Our Deployment is in progress now.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VtM-VU-CvqONuvgDY86z2g.png" /><figcaption>Deployment in progress</figcaption></figure><p>When our deployment is complete. We can click on <em>Go to resource </em>to access our deployed App Service without our project at this point.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N2ncR-7PV-lgUjMm5tDIow.png" /><figcaption>Deployment complete</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VEra3V9pMNX8ZAyN_FaK-g.png" /><figcaption>App Service resource page</figcaption></figure><p>Below is the web page deployed by our App Service. If you used the exact name we used. You can access it on your browser with <a href="https://mywebapp110.azurewebsites.net/">mywebapp110.azurewebsites.net</a> (or whatever name is on your Resource Page).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v99O2Dp8uPOL_E_MQtMALg.png" /><figcaption>Deployed App Service website</figcaption></figure><blockquote><em>Excersice 2: Deploy our project to App Service on Azure</em></blockquote><p>First, Open the cloned or created project on your <strong>Visual studio code</strong> then test that is building and running perfectly by using the command <em>dotnet run. </em>Next, make sure the project you wish you deploy is on the master branch. If not, create a branch called master it doesn’t already exist with “<em>git checkout -b master</em>” and then merge to the branch you have your project with “<em>git merge &lt;branch&gt;</em>”. When this is done, you have your files in the master branch. Go back to the App Service resource page, and click on <strong>Deployment Center</strong> on the left pane under the Deployment section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*TPyBzoYUsrj5vLlrxQYvDg.png" /><figcaption>App Service</figcaption></figure><p>In the <strong>settings </strong>tab, select <em>Local Git</em> in the dropdown for S<strong>ource </strong>and click Save which will set up your deployment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/1*eY8Y50f7eEWSq-d2JeJL1g.png" /></figure><p>Next, copy the <strong>Git Clone Uri, </strong>then go to your Visual Studio code terminal. In the terminal, make sure you are in the directory of your project. Use the following command to add Azure to your project for remote access: “<em>git remote add azure &lt;Git Clone Uri&gt;</em>”.</p><p>Next, go to the <strong>Local Git/FTPS credentials</strong> tab to access the credentials for deploying your project. You would need the Application Scope Username and Password auto-generated by Azure App Service.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*HEaGR0o-C4uJrN6_UJtJvg.png" /></figure><p>Go back to your <strong>Visual Studio Code terminal</strong>. Type the following command “<em>git push azure master</em>” to deploy your code to the App Service. This will trigger a <strong>Windows security popup for Git credentials</strong>. On this popup, you’ll pass the auto-generated <strong>Username</strong>(starting after \) and <strong>Password</strong> then press Enter</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/452/1*oUGKY7dbxCNhGv-zTYn_ZA.png" /><figcaption>Authenticating Git credential</figcaption></figure><p>If you input the right credentials, your project deployment would resume right there on your terminal. If it is successful, you’d get a <strong>Deployment successful </strong>as part of the logs displayed to you on your terminal. Now you can go on the Url given earlier (<a href="https://mywebapp110.azurewebsites.net/"><em>mywebapp110.azurewebsites.net</em></a>) to confirm your deployment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-M1iBGO98jf0vMxh7LQyJA.png" /><figcaption>A successful deployed project</figcaption></figure><p>In this tutorial, you have learned how to deploy a .<strong>Net 6 AspNet MVC application to Azure App Service using our Local Git</strong>. In a different article, we would show how to use Custom domains on our Azure App service.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=610e734f1ccd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating an Azure SQL Database, with .Net6 Rest API]]></title>
            <link>https://medium.com/@eghosagabriel/creating-an-azure-sql-database-with-net6-rest-api-a5595ba9d84d?source=rss-e7e416df85f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/a5595ba9d84d</guid>
            <category><![CDATA[azure-sql-database]]></category>
            <category><![CDATA[paas]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[api-development]]></category>
            <category><![CDATA[dotnet]]></category>
            <dc:creator><![CDATA[Emmanuel Gabriel]]></dc:creator>
            <pubDate>Sat, 21 May 2022 16:06:10 GMT</pubDate>
            <atom:updated>2022-06-12T18:52:03.239Z</atom:updated>
            <content:encoded><![CDATA[<h3>Creating an Azure SQL Database, with .Net6 Rest API</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/1*iHyPirIOr8unnVpH622PAA.png" /></figure><p><strong>Summary</strong>: in this tutorial, you will learn how to create a single <strong>Azure SQL Database single database</strong>, and connect it to your <strong>.Net6 Rest API</strong> using the Azure SQL single database as a datastore.</p><p>Azure SQL Databases is a platform-as-a-service (PAAS) offering of Microsoft Azure. You can provision, connect and manage Azure SQL Database on the Azure portal, a PowerShell script, or an Azure CLI script. You can also query the database using the Query editor in the Azure portal.</p><p>Since we already have the source code in the <a href="https://github.com/Virifortissimi/MinimalAPI">repo</a>. You could just clone it and use it for this tutorial. You can also create your project if you wish to create one from scratch. The source code is a Todo API.</p><blockquote>Prerequisites</blockquote><ul><li><a href="https://visualstudio.microsoft.com/vs/#download">Visual Studio 2022</a> with the ASP.NET and web development workload.</li><li>Active Azure Account</li></ul><blockquote>Exercise 1: Create Azure SQL Database on Azure</blockquote><p>Sign in to your Azure account at <a href="https://portal.azure.com/">https://portal.azure.com</a>. If you do not already have one, create an account to get a $200 Azure credit. You’ll have 30days to use this credit in addition to free resources available on the portal.</p><p>When signed in, Go to the <a href="https://portal.azure.com/#create/Microsoft.AzureSQL">Select SQL Deployment Page</a>. Under SQL Databases, Leave the Resource Type to Single Databases then click Create.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pxvRA2Zn7IYqj5DcLQEB5A.png" /><figcaption>SQL Deployment Option</figcaption></figure><p>On the Basics Tab. Select your preferred <strong>Subscription</strong>. For the <strong>Resource group</strong>, click on Create new and type in <em>TodoAPIRG. </em>For the <strong>Database name, </strong>Enter in <em>TodoAPIDB. </em>So far, the basics tab should look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/733/1*MlZHkGpPHEBQXjyuSLsapQ.png" /><figcaption>Basics tab</figcaption></figure><p>Next, click on Create new for Server which would open a new page to create your server details. For the <strong>Server name</strong>, enter <em>todoapisvr. </em>For the <strong>Location, </strong>pick a location that is closest to you. For the <strong>Authentication method, </strong>leave it on Use SQL Authentication. Then select a <strong>Server Admin Login</strong> and <strong>Password</strong> of your choice. Click on OK.</p><p>Back to the Basics tab, leave <strong>Want to use SQL elastic pool</strong> set to No. Click on Configure database for<strong> Compute + Storage</strong>. On the Service tier dropdown, you can configure for whatever compute you prefer but for this article, select <em>Basic (For less demanding workloads) </em>then Select Apply.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/1*iLn-B-_r5i3X_GqTbuVFzQ.png" /><figcaption>Configure</figcaption></figure><p>The Basics tab should look like the image below, Click <strong>Next: Networking</strong> to go to the Networking tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*IEy6rKGli9qlaWA9K6sl0g.png" /><figcaption>Network tab</figcaption></figure><p>In the Networking tab, For <strong>Network Connectivity</strong>, select the <em>Public Endpoint</em> option. For <strong>Firewall Rules, </strong>set <em>Allow Azure services and resources to access this server </em>to Yes (This would allow for our API when hosted on Azure App Service to access the SQL Database. We would handle that in a different tutorial) and <em>Add current client IP address</em> to Yes as well. The Networking tab should look like the image below. Click <strong>Next: Security</strong> to go to the Security tab</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*0yfOqlqAH-IiH3QWzuLdIw.png" /><figcaption>Security tab</figcaption></figure><p>On the Security tab, you have the option of <strong>Enabling Microsoft Defender for SQL</strong>. You also have the option of Using system-assigned and user-assigned managed identities to enable central access management between this database and other Azure resources. You can learn more about this <a href="https://go.microsoft.com/fwlink/?linkid=2161107">here</a>.</p><p>You can Select <strong>Review + Create </strong>to review all selected options and create your SQL Database. On the <strong>Review + create </strong>tab<strong>, </strong>Select create.</p><p>Sit back, relax and allow Azure to provision you a SQL Database 😃</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EH-iNWfpATyWJW8hwkpmyw.png" /><figcaption>Deployment in progress</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/1*9UP2tWNSAwbzYIeSS7OaQQ.png" /><figcaption>Deployment complete</figcaption></figure><p>If you’ve gotten this far, pat yourself on the back because you’ve just provisioned an SQL Database on Azure.</p><blockquote>Exercise 2: Connecting your Azure SQL Database your local .Net6 project</blockquote><p>To connect the Azure SQL Database to our local dotnet project. We need to get the connectionstrings. Click on <strong>Go to resource</strong> on the deployment complete page.</p><p>On the SQL Database resource page, Click on Show Database connection strings and copy the connection string for Ado.net.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X00KO3Ulx5iyWxzFS2vHlg.png" /></figure><p>Next, Clone the project from <a href="https://github.com/Virifortissimi/MinimalAPI">here</a> or create your project from scratch. When you have the project on your machine. Paste the copied connection string in the <strong>appsettings.development.json</strong> file, then replace <em>{your_password} </em>with the password used in creating your server. It should look like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/65e15be6eefb23494b349dee5f186ebf/href">https://medium.com/media/65e15be6eefb23494b349dee5f186ebf/href</a></iframe><p>Next, we need to update the <strong>Azure SQL Database</strong> using the migrations file on our project. If there isn’t any migrations file. Create one.</p><p>Click on Tools →NuGet Package Manager →Package Manager Console to open the Package Manager Console. In the package manager console, Change the directory into the project by typing “<em>cd .\MinimalAPI</em>”.</p><p>Next, create migration by typing “<em>dotnet ef migrations add InitMigration</em>” which would create a migration file.</p><p>If you already have a migrations file, update the database with the command “<em>dotnet ef database update</em>”.</p><blockquote>Exercise 3: Confirm that we are using Azure SQL Database with our project</blockquote><p>Great job so far. We can now confirm that we are using <strong>Azure SQL Database</strong> with our project on local by clicking on<strong> Query editor</strong> on our resource page, then put in our <strong>server login</strong> and <strong>password</strong> in their respective fields. When done, select Ok.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SRTmYREBMDAceOi2fRTKRA.png" /></figure><p>As you can see, the <strong>TodoItems table</strong> has been updated on our <strong>Azure SQL table</strong>. Now let persist data into the database by running a Create operation. Run the project on Visual Studio and Create a Todo Item.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*_o9yV87bGU8RB-NNi_inCg.png" /></figure><p>Our TodoItem has successfully been created. Next, let&#39;s check the <strong>Query Editor</strong> again to confirm that our Todo Item persisted in <strong>Azure SQL Database.</strong> Click on the options button beside dbo.TodoItems and select Top 1000 Rows. The result below shows our Todo Item was persisted in the Database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K39CVQnyKpiWHJXPcqGzWg.png" /></figure><p>In this tutorial, you have learned how to provision an Azure SQL Database single database and use that database in our .Net6 Rest API. In our next article, we would deploy our Rest API to Azure App Service.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a5595ba9d84d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting Up Minimal.Net6 Rest API with SQL Server.]]></title>
            <link>https://medium.com/@eghosagabriel/setting-up-minimal-net6-rest-api-with-sql-server-78cb37839eb6?source=rss-e7e416df85f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/78cb37839eb6</guid>
            <category><![CDATA[dotnet6]]></category>
            <category><![CDATA[api-development]]></category>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[minimal-api]]></category>
            <category><![CDATA[dotnet-core]]></category>
            <dc:creator><![CDATA[Emmanuel Gabriel]]></dc:creator>
            <pubDate>Sat, 21 May 2022 12:26:02 GMT</pubDate>
            <atom:updated>2022-06-12T18:48:57.474Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/663/1*VMlo40h4jbaNk6-L5av5gg.png" /></figure><p><strong>Summary</strong>: in this tutorial, you will learn how to set up a minimal dotnet6 Rest API using SQL Server as the datastore.</p><p>According to the Microsoft Docs: Minimal APIs (Introduced with the .Net6 framework) are architected to create HTTP APIs with minimal dependencies. They are ideal for microservices and apps that want to include only the minimum files, features, and dependencies in ASP.NET Core.</p><p>I particularly find minimal APIs exciting because you could in about 10 minutes set up an API with a few endpoints. We are going to build a Todo API with CRUD abilities.</p><blockquote><strong>The following illustration shows the completed swagger documentation for the API with all CRUD operations implemented.</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SPbdHj9cPo7npk9xTiqFdg.png" /></figure><blockquote><strong>Prerequisites</strong></blockquote><ul><li><a href="https://visualstudio.microsoft.com/vs/#download">Visual Studio 2022</a> with the ASP.NET and web development workload.</li></ul><p>or</p><ul><li><a href="https://code.visualstudio.com/download">Visual Studio Code</a></li><li><a href="https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp">C# for Visual Studio Code (latest version)</a></li><li><a href="https://dotnet.microsoft.com/download/dotnet/6.0">.NET 6.0 SDK</a></li></ul><p>or</p><ul><li><a href="https://visualstudio.microsoft.com/vs/mac/preview/">Visual Studio 2022 for Mac latest preview</a></li></ul><p>and</p><ul><li><a href="https://www.microsoft.com/en-us/sql-server/sql-server-downloads">SQL Server Express</a></li></ul><p>For this article. I would be working with <strong>Visual Studio 2022</strong>. You could follow through and create yours as you read the article or you could just get the <a href="https://github.com/Virifortissimi/MinimalAPI">source code</a> and look through the code</p><blockquote><strong>Step 1:</strong></blockquote><p>Create a minimal dotnet API by opening up <strong>Visual Studio</strong> and selecting “<strong>Create a new project</strong>”.</p><figure><img alt="Visual Studio" src="https://cdn-images-1.medium.com/max/1015/1*TunxbhAnRHzIGyNk1Zf_yA.png" /><figcaption>Visual Studio 2022</figcaption></figure><p>Select the <strong>ASP.NET Core Web API</strong> Project with C# language as there is a different Project for F#. Click Next</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1014/1*lgLBYlL23q9Et77yImsXHw.png" /><figcaption>Create a new project</figcaption></figure><p>Configure your new project by giving it a name. In our case, we are simply naming it <strong>MininalAPI</strong>. Click Next when done configuring your project</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1014/1*ZlcCrJ0yaPBSe68LWGjduA.png" /><figcaption>Configure your new project</figcaption></figure><p>Uncheck the “<strong>Use controllers</strong>” checkbox to make sure that controllers would not be added to the created project. We’d be working mostly with the program class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1014/1*gD-ygpPmuu8fT8HpEs1HMw.png" /><figcaption>Uncheck use controllers</figcaption></figure><p>Click Create. A simple <strong>Webapi project</strong> would be created for you without a controller folder but with a Program class that looks exactly like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8ab171390d610ea27dc01b6fbb560d46/href">https://medium.com/media/8ab171390d610ea27dc01b6fbb560d46/href</a></iframe><p>Clean up the project by deleting the internal Record WeatherForecast class, the Get Route, and the summaries array sections on your <strong>Program.cs </strong>class to make it look exactly like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1dc939d3ef93c22d459402868421d22e/href">https://medium.com/media/1dc939d3ef93c22d459402868421d22e/href</a></iframe><blockquote>Step 2</blockquote><p>Now let’s install the nuget packages that we require to use SQL Server as our data store. The packages are:</p><ol><li>Microsoft.EntityFrameworkCore.Design (latest stable dotnet 6 version)</li><li>Microsoft.EntityFrameworkCore.SqlServer (latest stable dotnet 6 version)</li><li>Microsoft.EntityFrameworkCore (latest stable dotnet 6 version)</li><li>Tools (can be gotten with the command <em>“dotnet tool install — global dotnet-ef”</em></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/905/1*59X1qpVPHvxS3G6O30TtQA.png" /><figcaption>nuget packages</figcaption></figure><p>Next, at the root of your project, add a new class called <strong>TodoItem</strong>. Add the following to the class.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ccc0b9ac4acb978210c999f7050047ab/href">https://medium.com/media/ccc0b9ac4acb978210c999f7050047ab/href</a></iframe><p>Also, create a <strong>DataContext </strong>class at the root of your project with the following code added to it.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6601247136ecc77ee0ec68f702230927/href">https://medium.com/media/6601247136ecc77ee0ec68f702230927/href</a></iframe><p>The <strong>DataContext</strong> class would inherit from<strong> DbContext</strong>, then a constructor is created to get <strong>DbContextOptions</strong> of our <strong>DataContext</strong> class which would be passed to the base class. A DbSet of our <strong>TodoItem</strong> is also added which represents our <strong>TodoItem</strong> Entity and can be used for creating, reading, updating, and deleting operations.</p><p>Next, Update your <strong>appsetting.Development.json</strong> to contain the connectionString for our data store.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d301f348e30c1d2dbdea8676d8036425/href">https://medium.com/media/d301f348e30c1d2dbdea8676d8036425/href</a></iframe><p>Next, Update our <strong>Program </strong>class by registering a new Service. The <strong>AddDbContext </strong>service<strong> </strong>which would use SQL Server and would get the connectionstrings from<strong> builder.Configuration.</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7e3cde5568dd52bda1887029eed746d0/href">https://medium.com/media/7e3cde5568dd52bda1887029eed746d0/href</a></iframe><p>We are using the Code First Approach in creating our Database so we would need to create a migrations folder. EntityFramework is going to come to our rescue here. We would use the following commands to create our migrations folder and update our database.</p><p>Click on Tools →NuGet Package Manager →Package Manager Console to open the Package Manager Console. In the package manager console, Change the directory into the project by typing “<em>cd .\MinimalAPI</em>”.</p><p>Next, create migration by typing “<em>dotnet ef migrations add InitialMigration</em>” which would create a migration file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/953/1*PhJX6an-jl_KbIrO9zG7wA.png" /><figcaption>Migration file</figcaption></figure><p>Updating our database with the command “<em>dotnet ef database update</em>” would create the database on SQL Server and also create the TodoItems Table as we see in the image below:</p><figure><img alt="Database" src="https://cdn-images-1.medium.com/max/1024/1*_3LagHCbwsNh7bweNdXEww.png" /><figcaption>SQL Server Managaement Studio</figcaption></figure><p>Now it’s time to add our CRUD operations to the API.</p><blockquote>Step 3</blockquote><p>Add the following codes to the <strong>Program </strong>class, just after the <strong>app.UseHttpsRedirection()</strong> middleware.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/971fbc0dd2d74fa2f9cfa427a6b0948c/href">https://medium.com/media/971fbc0dd2d74fa2f9cfa427a6b0948c/href</a></iframe><p>We’ve just added 4 different types of routes (Get, Post, Put, Delete) using patterns we were already familiar with. We also passed in <strong>DataContext </strong>as a dependency to the RequestDelegate so as to access the Database.</p><p>In this tutorial, you have learned how to set up a .<strong>Net6 minimal Rest API with SQL Server as a datastore</strong>. In our next article, we <a href="https://medium.com/@eghosagabriel/creating-an-azure-sql-database-with-net6-rest-api-a5595ba9d84d">created an Azure SQL Database single database on Azure and used it on our project</a>. Read <a href="https://medium.com/@eghosagabriel/creating-an-azure-sql-database-with-net6-rest-api-a5595ba9d84d"><strong>HERE</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=78cb37839eb6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Connect To PostgreSQL Database Server with Entity Framework (Code First Approach)]]></title>
            <link>https://medium.com/@eghosagabriel/connect-to-postgresql-database-server-with-entity-framework-code-first-approach-7630bbf0d133?source=rss-e7e416df85f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/7630bbf0d133</guid>
            <category><![CDATA[aspnet]]></category>
            <category><![CDATA[entity-framework]]></category>
            <category><![CDATA[entity-framework-core]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[aspnetcore]]></category>
            <dc:creator><![CDATA[Emmanuel Gabriel]]></dc:creator>
            <pubDate>Fri, 02 Oct 2020 08:33:57 GMT</pubDate>
            <atom:updated>2022-05-21T13:02:56.198Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*XIMVb4ZQRfSS4ZnI6WfH0Q.jpeg" /></figure><p><strong>Summary</strong>: In this tutorial, you will learn how to connect to the PostgreSQL database server in the ASPNET WEB API using EFCore Code First Approach.</p><p>According to <a href="https://www.postgresqltutorial.com/what-is-postgresql/">Postgres Tutorial</a>: PostgreSQL is an advanced, enterprise-class, and open-source relational database system. PostgreSQL supports both SQL (relational) and JSON (non-relational) querying.</p><p>PostgreSQL is a highly stable database backed by more than 20 years of development by the open-source community.</p><p>PostgreSQL is used as a primary database for many web applications as well as mobile and analytics applications.</p><p>To install PostgresSQL on your local server, please use this <a href="https://www.postgresqltutorial.com/postgresql-getting-started/">instruction</a>.</p><p><strong>Create an ASPNET WEB API</strong></p><p>First, use the following command from the terminal to create an ASPNET WEB API with the name PostGresAPI</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b7lEQUTJIs2XjZIeNjTnQA.png" /></figure><p>If you have created the WEB API project, navigate to the project and use the command “code .” to open the project in VS Code</p><p>We must install the below libraries using the NuGet package manager.</p><ul><li>Npgsql.EntityFrameworkCore.PostgreSQL</li><li>Microsoft.EntityFrameworkCore</li><li>Microsoft.EntityFrameworkCore.Tools</li><li>Microsoft.EntityFrameworkCore.Design</li></ul><p><strong>Connect to the PostgreSQL database using your project</strong></p><p>The following is the list of the connection parameters:</p><p><strong>database</strong>: the name of the database that you want to connect.</p><p><strong>user</strong>: the username used to authenticate.</p><p><strong>password</strong>: password used to authenticate.</p><p><strong>host</strong>: database server address e.g., localhost or an IP address.</p><p><strong>port</strong>: the port number that defaults to 5432 if it is not provided.</p><p>We can modify the appsettings.json with the below values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2RDwhJKPZE8PBqg-D-m34A.png" /></figure><p>By doing the above, We have added a database connection string to the settings file</p><p>Next, Let’s create models we can use to pass our entities into the database. Create a Models folder then create a Student class in the Models folder:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gQxalA81yB4TLPmVjquhAQ.png" /></figure><p>We can next create a “Data” folder and then create the “ApplicationDbContext” class in the Data folder then add the below code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ACYYmk4j2daFnCDz8Kwe7w.png" /></figure><p><strong>Make Changes to the ConfigureServices method in the Startup File</strong></p><p>We can make below changes in the “ConfigureServices” method in the “Startup” class as well to link the connection string and the Database context so as to create the file in our PostGresSQL database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kQrah0iq4NH_0ZPsP-qpVA.png" /></figure><p><strong>Create a Database table</strong></p><p>We can now create a database table. As we are using Entity Framework, we can use below database migration command from the terminal to create a migrations folder and then update the database.</p><p><em>dotnet ef migrations add InitialMigration</em></p><p>If successful, we should see the below message in the terminal and the migrations folder created</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DgePqxcwbHPbj4YY5NNcwA.png" /></figure><p>“InitialMigration” is the name we have given to the migrations. When successfully done, we can now update the database with the following command from the terminal also</p><p><em>dotnet ef database update</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nDO35__sQnC4nnft6VGPNA.png" /></figure><p>If you check the database using the PostgreSQL database server, you can see that the below table has been created inside the database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Uex5nCXwaAqaTfQ2SvQ9Qg.png" /><figcaption>The studentDb created in the PostgreSQL database server</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LAhO6LN8uIePC1K67ULL-A.png" /><figcaption>The students table created with Id and Name columns</figcaption></figure><p>In this tutorial, you have learned how to connect to the PostgreSQL database server in an ASPNET WEB API using Entity Framework Core Code first approach.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7630bbf0d133" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The journey has started…]]></title>
            <link>https://medium.com/@eghosagabriel/the-journey-has-started-eeba0401568e?source=rss-e7e416df85f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/eeba0401568e</guid>
            <dc:creator><![CDATA[Emmanuel Gabriel]]></dc:creator>
            <pubDate>Tue, 02 Apr 2019 08:02:48 GMT</pubDate>
            <atom:updated>2019-04-02T20:55:02.322Z</atom:updated>
            <content:encoded><![CDATA[<p>The journey has started…</p><p>My first task with Hotels.ng internship was to find a bug on <a href="http://timbu.com/">timbu</a>, who is a partner of HNG internship.</p><p>On my search, I found two bugs:</p><ul><li>The menu icon on mobile is not working</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*UZ_kXdxommc_rTqiTQW-5w.jpeg" /></figure><ul><li>The text on the first image content is not fully visible</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*kysDfeHuZjdHKOGh2XuFlg.jpeg" /></figure><ul><li>The images in the section where our guests went to would look better if center aligned from the max-width of 368px</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z1UOEjRmB-LyX3j_81ecdA.jpeg" /></figure><p>I must say I’m enjoying the internship thus far. As this first task is helping me keep a keen eye to details. Thanks <a href="http://hotels.ng/">hotelsng</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eeba0401568e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I finally brought myself to writing my first ever blog post...]]></title>
            <link>https://medium.com/@eghosagabriel/i-finally-brought-myself-to-writing-my-first-ever-blog-post-88eca89e379c?source=rss-e7e416df85f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/88eca89e379c</guid>
            <dc:creator><![CDATA[Emmanuel Gabriel]]></dc:creator>
            <pubDate>Mon, 01 Apr 2019 22:27:15 GMT</pubDate>
            <atom:updated>2019-04-01T22:27:15.234Z</atom:updated>
            <content:encoded><![CDATA[<p>I finally brought myself to writing my first ever blog post...</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6cLY2LeLyvqSoGCHo0brkA.jpeg" /></figure><p>Well, it’s been a long time coming. I wanted to write something but was never able to achieve that feat not until I got into the hotels.ng(HNG) internship and was mandated to write my first blog post.</p><p>I am excited to be able to face what awaits me and I’m sure you all would hear alot more from me henceforth. Don’t worry, I would also keep you all in the loop as to the HNG Internship.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=88eca89e379c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>