{"id":48586,"date":"2019-09-09T08:00:10","date_gmt":"2019-09-09T06:00:10","guid":{"rendered":"https:\/\/code-maze.com\/?p=48586"},"modified":"2022-01-13T10:51:11","modified_gmt":"2022-01-13T09:51:11","slug":"configure-postgresql-ef-core","status":"publish","type":"post","link":"https:\/\/code-maze.com\/configure-postgresql-ef-core\/","title":{"rendered":"How to Configure PostgreSQL in Entity Framework Core"},"content":{"rendered":"<p>In this article, we are going to learn how to configure <a href=\"https:\/\/www.postgresql.org\/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">PostgreSQL<\/a>, a popular and reliable open-source relational database, in our .NET Core application, and connect it to Entity Framework Core to utilize its full potential.<\/p>\n<p>If you want to learn more about Entity Framework Core and how to configure it properly, check out our <a href=\"https:\/\/code-maze.com\/entity-framework-core-series\/\" target=\"_blank\" rel=\"noopener noreferrer\">EF Core Series<\/a>.<\/p>\n<p>You can download\u00a0<a href=\"https:\/\/github.com\/CodeMazeBlog\/postgresql-ef-core\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">the source code<\/a>\u00a0for this article on our GitHub repository.<\/p>\n<p>Let&#8217;s get down to it.<\/p>\n<h2><a id=\"installation\"><\/a>Installing PostgreSQL Server and pgAdmin<\/h2>\n<p>First off, we need to install our PostgreSQL Server and client. Download the appropriate version of <a href=\"https:\/\/www.postgresql.org\/download\/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">PostgreSQL for your OS<\/a> and select the newest version available.<\/p>\n<p>During the installation, you will be prompted to select pgAdmin (client). There are several good clients for PostgreSQL, but pgAdmin is the standard one, and a good one to begin with. Once you get used to it, you can try out other ones.<\/p>\n<p>You will also be prompted for a superuser (postgresql) password. This password is the master password and you should make sure to remember it or write it down. You can leave the port on 5432 which is the default PostgreSQL port to avoid confusion. (You can choose another one if you already have a PostgreSQL server on your machine)<\/p>\n<p>Finish the wizard and we&#8217;re ready to start.<\/p>\n<h2><a id=\"dependencies\"><\/a>Installing the Required Dependencies for PostgreSQL<\/h2>\n<p>To enable PostgreSQL support in our Web API application, we need to install the dependencies for PostgreSQL in our application first:<\/p>\n<p>We can do that by using the Package Manager Console:<\/p>\n<p><code>Install-Package Npgsql.EntityFrameworkCore.PostgreSQL -Version 2.2.4<\/code><\/p>\n<p>Or by using the dotnet CLI:<\/p>\n<p><code>dotnet add package Npgsql.EntityFrameworkCore.PostgreSQL --version 2.2.4<\/code><\/p>\n<p>We are going to hardcode it to version 2.2.4 since that is the newest version right now.<\/p>\n<p>Npgsql is the Entity Framework Core PostgreSQL provider. And that&#8217;s all we need in regards to external dependencies for this project. Everything else we&#8217;ve already got out of the box.<\/p>\n<p>Let&#8217;s see how hard it is to configure PostgreSQL in our Web API app.<\/p>\n<h2><a id=\"configuration\"><\/a>Configuring the PostgreSQL Provider and Connection String<\/h2>\n<p>To configure our application and play around a bit with PostgreSQL, we need to add some code to the Startup.cs first.<\/p>\n<p>Let&#8217;s modify our <code>ConfigureServices()<\/code> method:<\/p>\n<p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-highlight=\"5-13\" data-enlighter-title=\"Startup.cs\">public void ConfigureServices(IServiceCollection services)\r\n{\r\n\tservices.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);\r\n\r\n\tvar connectionString = Configuration[&quot;PostgreSql:ConnectionString&quot;];\r\n\tvar dbPassword = Configuration[&quot;PostgreSql:DbPassword&quot;];\r\n\r\n\tvar builder = new NpgsqlConnectionStringBuilder(connectionString)\r\n\t{\r\n\t\tPassword = dbPassword\r\n\t};\r\n\r\n\tservices.AddDbContext&lt;ApplicationContext&gt;(options =&gt; options.UseNpgsql(builder.ConnectionString));\r\n}<\/pre><\/p>\n<p>Aside from the <code>AddMvc()<\/code> method, everything else is what we need to configure our database.<\/p>\n<p>We are populating the connection string and password from the configuration file.<\/p>\n<p><em><strong>Don&#8217;t do this for real-world projects, use secrets mechanism and environment variables instead. <\/strong><\/em><\/p>\n<p>Then, we&#8217;re using the <code>NpgsqlConnectionStringBuilder<\/code> to build our PostgreSQL connection string, and finally, connect ApplicationContext to the database using that connection string.<\/p>\n<p>ApplicationContext is a simple DbContext class:<\/p>\n<pre  class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\" title=\"ApplicationContext.cs\">public class ApplicationContext : DbContext\r\n{\r\n\tpublic ApplicationContext(DbContextOptions options)\r\n\t\t\t: base(options)\r\n\t{\r\n\t}\r\n\r\n\tpublic DbSet&lt;Student&gt; Students { get; set; }\r\n}<\/pre>\n<p>And we have one <code>DbSet<\/code> defined of the type <code>Student<\/code>.<\/p>\n<pre  class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\" title=\"Student.cs\">public class Student\r\n{\r\n\tpublic Guid Id { get; set; }\r\n\tpublic string Name { get; set; }\r\n\tpublic int Age { get; set; }\r\n}<\/pre>\n<p>That&#8217;s it for the configuration.<\/p>\n<p>Now let&#8217;s simply add the Students table to our database. We are going to use the <a href=\"https:\/\/code-maze.com\/net-core-web-api-ef-core-code-first\/\" target=\"_blank\" rel=\"noopener noreferrer\">Code-First approach<\/a> for this and create a migration to update our database with.<\/p>\n<p>First, let add a migration in the Package Manager Console:<\/p>\n<p><code>PM&gt; Add-Migration InitialEntities<\/code><\/p>\n<p>And then update our database:<\/p>\n<p><code>PM&gt; Update-Database<\/code><\/p>\n<p>Our database should contain the table &#8220;Students&#8221; now and we&#8217;re all set to play around with some queries.<\/p>\n<h2><a id=\"query\"><\/a>Writing a Simple Query to Insert Data in PostgreSQL<\/h2>\n<p>First, let&#8217;s prepare our Controller for the Actions we need. Let&#8217;s repurpose ValuesController we get out-of-the-box and rename it to something more appropriate like the StudentsController.<\/p>\n<p>After that, let&#8217;s do some cleanup, and add the methods we need to try our database out.<\/p>\n<pre  class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\" title=\"StudentsController.cs\">[Route(\"api\/[controller]\")]\r\n[ApiController]\r\npublic class StudentsController : ControllerBase\r\n{\r\n\tprivate readonly ApplicationContext _context;\r\n\r\n\tpublic StudentsController(ApplicationContext context)\r\n\t{\r\n\t\t_context = context;\r\n\t}\r\n\r\n\t[HttpGet]\r\n\tpublic IActionResult Get()\r\n\t{\r\n\t\treturn Ok();\r\n\t}\r\n\r\n\t[HttpGet(\"{id}, Name = \"GetById\")]\r\n\tpublic IActionResult Get(string id)\r\n\t{\r\n\t\tvar student = _context.Find&lt;Student&gt;(Guid.Parse(id));\r\n\r\n\t\treturn Ok(student);\r\n\t}\r\n\r\n\t[HttpPost]\r\n\tpublic IActionResult Post([FromBody] Student student)\r\n\t{\r\n\t\t_context.Add(student);\r\n\r\n\t\t_context.SaveChanges();\r\n\r\n\t\treturn CreatedAtRoute(nameof(GetById), new { id = student.Id }, student);\r\n\t}\r\n}<\/pre>\n<p>This is a simple controller, and all it has is three methods:<\/p>\n<p><code>GET api\/students<\/code><br \/>\n<code>GET api\/students\/{id}<\/code><br \/>\n<code>POST api\/students<\/code><\/p>\n<p>Let&#8217;s use our POST method to insert some data into the database. For this purpose, we like to use Postman, but feel free to use any client of your choice.<\/p>\n<p>Let&#8217;s add Chris Pratt to our Students table (although he might not be interested in programming classes):<\/p>\n<p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-title=\"\">{\r\n\t&quot;Name&quot;: &quot;Chris Pratt&quot;,\r\n\t&quot;Age&quot;: &quot;40&quot;\r\n}<\/pre><\/p>\n<p>Here&#8217;s the Postman request:<\/p>\n<p><a href=\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/08\/insert-request-postman.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-48588\" src=\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/08\/insert-request-postman.png\" alt=\"insert request postman\" width=\"771\" height=\"473\" srcset=\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/08\/insert-request-postman.png 771w, https:\/\/code-maze.com\/wp-content\/uploads\/2019\/08\/insert-request-postman-300x184.png 300w, https:\/\/code-maze.com\/wp-content\/uploads\/2019\/08\/insert-request-postman-768x471.png 768w\" sizes=\"auto, (max-width: 771px) 100vw, 771px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>As you can see, we got the <code>201 Created<\/code> response, which means we successfully created a new student.<\/p>\n<p>And to be sure, let&#8217;s check the pgAdmin:<\/p>\n<p><a href=\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/08\/pgAdmin-result.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-48589\" src=\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/08\/pgAdmin-result.png\" alt=\"pgAdmin result\" width=\"422\" height=\"226\" srcset=\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/08\/pgAdmin-result.png 422w, https:\/\/code-maze.com\/wp-content\/uploads\/2019\/08\/pgAdmin-result-300x161.png 300w\" sizes=\"auto, (max-width: 422px) 100vw, 422px\" \/><\/a><\/p>\n<p>If you see this record, that means you&#8217;ve completed everything successfully until this point.<\/p>\n<p>Great.<\/p>\n<p>Let&#8217;s read some data.<\/p>\n<h2><a id=\"readingdata\"><\/a>Reading Data from PostgreSQL<\/h2>\n<p>Now to finish this example off, let&#8217;s use postman to read our new student from the database.<\/p>\n<p>To do that, let&#8217;s request a student we&#8217;ve just created.<\/p>\n<p>Since we know that we&#8217;ve added Chris Pratt recently and what his id is, our request should be (you&#8217;ll have a different id, which EF Core generates automatically):<\/p>\n<p><code>https:\/\/localhost:5001\/api\/students\/e4624adb-c03d-4c86-80b8-0c255960ec54<\/code><\/p>\n<p>Here&#8217;s the Postman request:<\/p>\n<p><a href=\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/08\/get-request-postman.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-48591\" src=\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/08\/get-request-postman.png\" alt=\"get request postman\" width=\"793\" height=\"358\" srcset=\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/08\/get-request-postman.png 793w, https:\/\/code-maze.com\/wp-content\/uploads\/2019\/08\/get-request-postman-300x135.png 300w, https:\/\/code-maze.com\/wp-content\/uploads\/2019\/08\/get-request-postman-768x347.png 768w\" sizes=\"auto, (max-width: 793px) 100vw, 793px\" \/><\/a><\/p>\n<p>This time we get the <code>200 OK<\/code> response, and Chris Pratt in the response.<\/p>\n<p>That was everything we needed.<\/p>\n<h2>Conclusion<\/h2>\n<p>As you can see, working with PostgreSQL is not much different than working with MSSQL or MySQL that we&#8217;ve covered so far.<\/p>\n<p>So to sum it up, in this article we&#8217;ve learned:<\/p>\n<ul>\n<li>How to install PostgreSQL server<\/li>\n<li>Configure the PostgreSQL provider and our application to use it<\/li>\n<li>How to make some simple requests to insert and read data from PostgreSQL<\/li>\n<\/ul>\n<p>&nbsp;<\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this article, we are going to learn how to configure PostgreSQL, a popular and reliable open-source relational database, in our .NET Core application, and connect it to Entity Framework Core to utilize its full potential. If you want to learn more about Entity Framework Core and how to configure it properly, check out our [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":54972,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"categories":[12],"tags":[79,85,146,556,84,343,555],"class_list":["post-48586","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-csharp","tag-asp-net-core","tag-aspnetcore","tag-configuration","tag-database","tag-dotnetcore","tag-ef-core","tag-postgresql","et-has-post-format-content","et_post_format-et-post-format-standard"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Configure PostgreSQL in Entity Framework Core - Code Maze<\/title>\n<meta name=\"description\" content=\"In this article, we are going to learn how to configure PostgreSQL, a popular and reliable open-source relational database in our .NET Core application.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/code-maze.com\/configure-postgresql-ef-core\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Configure PostgreSQL in Entity Framework Core - Code Maze\" \/>\n<meta property=\"og:description\" content=\"In this article, we are going to learn how to configure PostgreSQL, a popular and reliable open-source relational database in our .NET Core application.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/code-maze.com\/configure-postgresql-ef-core\/\" \/>\n<meta property=\"og:site_name\" content=\"Code Maze\" \/>\n<meta property=\"article:published_time\" content=\"2019-09-09T06:00:10+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-01-13T09:51:11+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/09\/postgresql-ef-core.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1100\" \/>\n\t<meta property=\"og:image:height\" content=\"620\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Vladimir Pecanac\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/PecanacVladimir\" \/>\n<meta name=\"twitter:site\" content=\"@CodeMazeBlog\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Vladimir Pecanac\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":[\"Article\",\"BlogPosting\"],\"@id\":\"https:\/\/code-maze.com\/configure-postgresql-ef-core\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/code-maze.com\/configure-postgresql-ef-core\/\"},\"author\":{\"name\":\"Vladimir Pecanac\",\"@id\":\"https:\/\/code-maze.com\/#\/schema\/person\/50de31ad4e1992752e972e4715d93739\"},\"headline\":\"How to Configure PostgreSQL in Entity Framework Core\",\"datePublished\":\"2019-09-09T06:00:10+00:00\",\"dateModified\":\"2022-01-13T09:51:11+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/code-maze.com\/configure-postgresql-ef-core\/\"},\"wordCount\":830,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\/\/code-maze.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/code-maze.com\/configure-postgresql-ef-core\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/09\/postgresql-ef-core.png\",\"keywords\":[\"asp.net core\",\"aspnetcore\",\"configuration\",\"database\",\"dotnetcore\",\"EF Core\",\"PostgreSQL\"],\"articleSection\":[\"C#\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/code-maze.com\/configure-postgresql-ef-core\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/code-maze.com\/configure-postgresql-ef-core\/\",\"url\":\"https:\/\/code-maze.com\/configure-postgresql-ef-core\/\",\"name\":\"How to Configure PostgreSQL in Entity Framework Core - Code Maze\",\"isPartOf\":{\"@id\":\"https:\/\/code-maze.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/code-maze.com\/configure-postgresql-ef-core\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/code-maze.com\/configure-postgresql-ef-core\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/09\/postgresql-ef-core.png\",\"datePublished\":\"2019-09-09T06:00:10+00:00\",\"dateModified\":\"2022-01-13T09:51:11+00:00\",\"description\":\"In this article, we are going to learn how to configure PostgreSQL, a popular and reliable open-source relational database in our .NET Core application.\",\"breadcrumb\":{\"@id\":\"https:\/\/code-maze.com\/configure-postgresql-ef-core\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/code-maze.com\/configure-postgresql-ef-core\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/code-maze.com\/configure-postgresql-ef-core\/#primaryimage\",\"url\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/09\/postgresql-ef-core.png\",\"contentUrl\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/09\/postgresql-ef-core.png\",\"width\":1100,\"height\":620,\"caption\":\"postgresql ef core\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/code-maze.com\/configure-postgresql-ef-core\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/code-maze.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Configure PostgreSQL in Entity Framework Core\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/code-maze.com\/#website\",\"url\":\"https:\/\/code-maze.com\/\",\"name\":\"Code Maze\",\"description\":\"Learn. Code. Succeed.\",\"publisher\":{\"@id\":\"https:\/\/code-maze.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/code-maze.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/code-maze.com\/#organization\",\"name\":\"Code Maze\",\"url\":\"https:\/\/code-maze.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/code-maze.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/01\/Code-Maze-Only-Logo-Transparent-HRez.png\",\"contentUrl\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/01\/Code-Maze-Only-Logo-Transparent-HRez.png\",\"width\":3511,\"height\":3510,\"caption\":\"Code Maze\"},\"image\":{\"@id\":\"https:\/\/code-maze.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/CodeMazeBlog\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/code-maze.com\/#\/schema\/person\/50de31ad4e1992752e972e4715d93739\",\"name\":\"Vladimir Pecanac\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/code-maze.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2016\/02\/profile_image-100x100.png\",\"contentUrl\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2016\/02\/profile_image-100x100.png\",\"caption\":\"Vladimir Pecanac\"},\"description\":\"Hi, my name is Vladimir Pecanac, and I am a full-time .NET developer and DevOps enthusiast. I created this blog so I can share the things I learn in the hope of both helping others and deepening my own knowledge of the topics I write about. The best way to learn is to teach.\",\"sameAs\":[\"https:\/\/www.linkedin.com\/in\/vladimir-pecanac\/\",\"https:\/\/x.com\/https:\/\/twitter.com\/PecanacVladimir\"],\"url\":\"https:\/\/code-maze.com\/author\/codemaze_blog\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Configure PostgreSQL in Entity Framework Core - Code Maze","description":"In this article, we are going to learn how to configure PostgreSQL, a popular and reliable open-source relational database in our .NET Core application.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/code-maze.com\/configure-postgresql-ef-core\/","og_locale":"en_US","og_type":"article","og_title":"How to Configure PostgreSQL in Entity Framework Core - Code Maze","og_description":"In this article, we are going to learn how to configure PostgreSQL, a popular and reliable open-source relational database in our .NET Core application.","og_url":"https:\/\/code-maze.com\/configure-postgresql-ef-core\/","og_site_name":"Code Maze","article_published_time":"2019-09-09T06:00:10+00:00","article_modified_time":"2022-01-13T09:51:11+00:00","og_image":[{"width":1100,"height":620,"url":"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/09\/postgresql-ef-core.png","type":"image\/png"}],"author":"Vladimir Pecanac","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/PecanacVladimir","twitter_site":"@CodeMazeBlog","twitter_misc":{"Written by":"Vladimir Pecanac","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["Article","BlogPosting"],"@id":"https:\/\/code-maze.com\/configure-postgresql-ef-core\/#article","isPartOf":{"@id":"https:\/\/code-maze.com\/configure-postgresql-ef-core\/"},"author":{"name":"Vladimir Pecanac","@id":"https:\/\/code-maze.com\/#\/schema\/person\/50de31ad4e1992752e972e4715d93739"},"headline":"How to Configure PostgreSQL in Entity Framework Core","datePublished":"2019-09-09T06:00:10+00:00","dateModified":"2022-01-13T09:51:11+00:00","mainEntityOfPage":{"@id":"https:\/\/code-maze.com\/configure-postgresql-ef-core\/"},"wordCount":830,"commentCount":1,"publisher":{"@id":"https:\/\/code-maze.com\/#organization"},"image":{"@id":"https:\/\/code-maze.com\/configure-postgresql-ef-core\/#primaryimage"},"thumbnailUrl":"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/09\/postgresql-ef-core.png","keywords":["asp.net core","aspnetcore","configuration","database","dotnetcore","EF Core","PostgreSQL"],"articleSection":["C#"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/code-maze.com\/configure-postgresql-ef-core\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/code-maze.com\/configure-postgresql-ef-core\/","url":"https:\/\/code-maze.com\/configure-postgresql-ef-core\/","name":"How to Configure PostgreSQL in Entity Framework Core - Code Maze","isPartOf":{"@id":"https:\/\/code-maze.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/code-maze.com\/configure-postgresql-ef-core\/#primaryimage"},"image":{"@id":"https:\/\/code-maze.com\/configure-postgresql-ef-core\/#primaryimage"},"thumbnailUrl":"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/09\/postgresql-ef-core.png","datePublished":"2019-09-09T06:00:10+00:00","dateModified":"2022-01-13T09:51:11+00:00","description":"In this article, we are going to learn how to configure PostgreSQL, a popular and reliable open-source relational database in our .NET Core application.","breadcrumb":{"@id":"https:\/\/code-maze.com\/configure-postgresql-ef-core\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/code-maze.com\/configure-postgresql-ef-core\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/code-maze.com\/configure-postgresql-ef-core\/#primaryimage","url":"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/09\/postgresql-ef-core.png","contentUrl":"https:\/\/code-maze.com\/wp-content\/uploads\/2019\/09\/postgresql-ef-core.png","width":1100,"height":620,"caption":"postgresql ef core"},{"@type":"BreadcrumbList","@id":"https:\/\/code-maze.com\/configure-postgresql-ef-core\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/code-maze.com\/"},{"@type":"ListItem","position":2,"name":"How to Configure PostgreSQL in Entity Framework Core"}]},{"@type":"WebSite","@id":"https:\/\/code-maze.com\/#website","url":"https:\/\/code-maze.com\/","name":"Code Maze","description":"Learn. Code. Succeed.","publisher":{"@id":"https:\/\/code-maze.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/code-maze.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/code-maze.com\/#organization","name":"Code Maze","url":"https:\/\/code-maze.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/code-maze.com\/#\/schema\/logo\/image\/","url":"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/01\/Code-Maze-Only-Logo-Transparent-HRez.png","contentUrl":"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/01\/Code-Maze-Only-Logo-Transparent-HRez.png","width":3511,"height":3510,"caption":"Code Maze"},"image":{"@id":"https:\/\/code-maze.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/CodeMazeBlog"]},{"@type":"Person","@id":"https:\/\/code-maze.com\/#\/schema\/person\/50de31ad4e1992752e972e4715d93739","name":"Vladimir Pecanac","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/code-maze.com\/#\/schema\/person\/image\/","url":"https:\/\/code-maze.com\/wp-content\/uploads\/2016\/02\/profile_image-100x100.png","contentUrl":"https:\/\/code-maze.com\/wp-content\/uploads\/2016\/02\/profile_image-100x100.png","caption":"Vladimir Pecanac"},"description":"Hi, my name is Vladimir Pecanac, and I am a full-time .NET developer and DevOps enthusiast. I created this blog so I can share the things I learn in the hope of both helping others and deepening my own knowledge of the topics I write about. The best way to learn is to teach.","sameAs":["https:\/\/www.linkedin.com\/in\/vladimir-pecanac\/","https:\/\/x.com\/https:\/\/twitter.com\/PecanacVladimir"],"url":"https:\/\/code-maze.com\/author\/codemaze_blog\/"}]}},"_links":{"self":[{"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/posts\/48586","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/comments?post=48586"}],"version-history":[{"count":2,"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/posts\/48586\/revisions"}],"predecessor-version":[{"id":63337,"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/posts\/48586\/revisions\/63337"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/media\/54972"}],"wp:attachment":[{"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/media?parent=48586"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/categories?post=48586"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/tags?post=48586"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}