Delete

Are you sure you want to delete this?

Info


Title
Set up .NET Core 3.1 to use MariaDb database
Content
<div class="container"> <p>To use a MariaDb database in combination with a .NET Core 3.1 Web Application and support database migrations requires a specific approach. Here are a few tips:</p> <p>In Visual Studio 2019, create a Web Application project and accept the default settings.</p> <p>If the Microsoft.EntityFrameworkCore package is not installed by default, use the following command line in the Package Manager Console window of Visual Studio 2019 to install the latest version:</p> <code><pre>PM&gt;Install-Package Microsoft.EntityFrameworkCore</pre></code> <h2>Use the Pomelo.EntityFrameworkCore.MySql database provider</h2> <p>Use this database provider, because currently (June 2020) the MySql.Data.EntityFrameworkCore data provider does not support .NET Core 3.1. </p> <p>See <a rel="noopener" href="https://dev.mysql.com/doc/connector-net/en/connector-net-entityframework-core.html" target="_blank">dev.mysql.com</a> to check if support has changed in the meantime.</p> <p>To install the Pomelo.EntityFrameworkCore.MySql database provider, enter the following command in the Package Manager Console window of Visual Studio 2019:</p> <code><pre>PM&gt;Install-Package Pomelo.EntityFrameworkCore.MySql</pre></code> <p>The github page is: <a rel="noopener" href="https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql">https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql</a></p> <h2>Add the MySqlConnector as a package to your Visual Studio project.</h2> <p>The MySqlConnector reference must be added to your Visual Studio project if you connect to a MariaDB MySQL database and want to use .NET migrations for the database. Enter the following command in the Package Manager Console window:</p> <code> <pre>PM&gt;Install-Package MySqlConnector</pre> </code> <p>The github page is: <a rel="noopener" href="https://www.nuget.org/packages/MySqlConnector/">https://www.nuget.org/packages/MySqlConnector/</a></p> <h3>Connection String</h3> <p>Put the database connection string in the Appsettings.json file of your Visual Studio project. For example:</p> <code><pre>&lt;server=localhost;user id=YourUserName;pwd=YourPassword;database=NameOfDatabase&gt;</pre></code> <h2>About MariaDB</h2> <p>MariaDb is developed by the same developers as MySQL. This database can be installed on various operating systems. Aside from .NET Framework and .NET Core, a variety of programming languages can connect to MariaDB.</p> <p>Visit the homepage to see what services Schouten offers. This includes the creation of applications (web and standalone) that use a MariaDB database among others.</p> <p><b>Applies to:</b></p> <p>.NET Core 3.1, Web Application, MariaDb database</p> <h3>New Article on processing JSON data from an external API</h3> <p>See also our new article on how to <a href="https://www.schoutentranslation.nl/knowledge-share/how-to-collect-json-from-an-api">process JSON data </a>from an (external) an API.</p> </div>
Excerpt
Set up .NET Core 3.1 to use MariaDb MySql database
CoverImagePath
/images/dotnetcode.jpg
Created
7-3-2020 09:56:36
Updated
4-1-2024 20:47:58
Views
9323
Public
| Back to List