diff options
[src] Removed manually placed heading anchors in all pages
1 files changed, 0 insertions, 6 deletions
| -rw-r--r-- | src/tutorials/connect-to-mysql-in-dotnet-ef/index.md | 6 |
diff --git a/src/tutorials/connect-to-mysql-in-dotnet-ef/index.md b/src/tutorials/connect-to-mysql-in-dotnet-ef/index.md index dfdb0c0..3a7c7d5 100644 --- a/src/tutorials/connect-to-mysql-in-dotnet-ef/index.md +++ b/src/tutorials/connect-to-mysql-in-dotnet-ef/index.md @@ -12,7 +12,6 @@ I have found that connecting a `.NET` application to a `MySql` database (with En Also, [MySql.Data.EntityFrameworkCore](https://www.nuget.org/packages/MySql.Data.EntityFrameworkCore/) has been **depricated** since *October 2020*. If you need setup instructions with it, read [this](https://gitlab.com/Syndamia/syndamiadotcom/-/blob/0510e29526c6d7681587fff4c98a339e8c69e9b5/src/tutorials/connect-to-mysql-in-csharp-ef/article.md). ## Contents -<div></div> 1. [NuGet packages](#nuget-packages) 2. [Connection string](#connection-string) @@ -21,12 +20,10 @@ Also, [MySql.Data.EntityFrameworkCore](https://www.nuget.org/packages/MySql.Data 2. [DBContext child class](#dbcontext-child-class) ## NuGet packages -[](#nuget-packages) You'll need to install [Pomelo.EntityFrameworkCore.MySql](https://www.nuget.org/packages/Pomelo.EntityFrameworkCore.MySql/). It provides the stuff necessary for connecting and using a `MySql` database. ## Connection string -[](#connection-string) There are [a lot](https://www.connectionstrings.com/mysql/) of ways to setup the connection string but I've found that this one works the best: @@ -39,7 +36,6 @@ If you are using `MySQL Workbench` and you don't know your port and id, you can  In this example, the user id is _root_ and the port is _3306_. ## Connecting -[](#connecting) To connect, you'll need to call the `UseMySql` method, either in [ASP.NET Startup](#asp.net-startup) or in a [DBContext child class](#dbcontext-child-class). @@ -56,7 +52,6 @@ For the server version argument, create a new object of type `MySqlServerVersion Where `CONNECTION_STRING` is a (constant) variable that contains your connection string, and 8, 0, 21 are the version numbers. ### ASP.NET Startup -[](#asp.net-startup) For `ASP.NET` applications, the connection must be put inside the `ConfigureServices` method of the `Startup.cs` file. If you already have a `.UseSQL` method call in there, just replace it with your `.UseMySql` method and arguments. @@ -74,7 +69,6 @@ The result should look something along the lines of: <p></p> ### DBContext child class -[](#dbcontext-child-class) Another way to connect is via a `DBContext` child class (so, inside your own DB context). Just, override the `OnConfiguring` method and call the `.UseMySql` method from the `optionsBuilder` parameter. |