From 64fbbd514733e42dd047bf65c511563a84ebd629 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Tue, 21 Jul 2020 23:17:07 +0300 Subject: Fully reworked website design. Remade pages in markdown. Configured files to work with ssg5. --- .../connect-to-mysql-in-csharp-ef/connecting.html | 81 ---------------------- 1 file changed, 81 deletions(-) delete mode 100644 website/tutorials/connect-to-mysql-in-csharp-ef/connecting.html (limited to 'website/tutorials/connect-to-mysql-in-csharp-ef/connecting.html') diff --git a/website/tutorials/connect-to-mysql-in-csharp-ef/connecting.html b/website/tutorials/connect-to-mysql-in-csharp-ef/connecting.html deleted file mode 100644 index c3fcdff..0000000 --- a/website/tutorials/connect-to-mysql-in-csharp-ef/connecting.html +++ /dev/null @@ -1,81 +0,0 @@ - - - - - - - - - - - - - Connect to MySql in C# and Entitiy Framework - Connecting - - - - - -
- -
- -
-

Connection string

-

- You can find many ways to impliment your connection string from here. - From experience, this one works the best:
-

- "server=localhost; port=YOUR-PORT; user id=YOUR-USER-ID; password=YOUR-PASSWORD; database=NAME-OF-DATABASE; SslMode=none" -

- If you don't know your port or user id, just look at the connection you use to connect to the database. -

-

- MyServer root 127.0.0.1:3306 - - In this example, the user id is root and the port is 3306. - -

-
-

ASP.NET Startup

-

- If you are making an ASP.NET application, you will need to alter your Startup.cs file. -

-

- Your ConfigureServices method should currenly look something like this: -

-  // This method gets called by the runtime. Use this method to add services to the container.
-  public void ConfigureServices(IServiceCollection services)
-  {
-   services.AddControllersWithViews();
-   services.AddTransient();
-   services.AddDbContext(opt =>
-   {
-    opt.UseSQL(CONNECTION_STRING);
-   });
-  } -

- You need to change .UseSQL to .UseMySQL (refer to preparations if you haven't already). -

-
-

DBContext child class

-

- If you want to connect a DBContext child class to a MySQL databse, the best way is to override the OnConfiguring method. In the override, in optionsBuilder, call the .UseMySQL method (refer to preparations if you haven't already). -

-

- Example: -

-  protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
-  {
-   optionsBuilder.UseMySQL(DataBaseContexts.ConnectionStringMySQL);
-  }
-

-

-
- -
- - - - - -- cgit v1.3.1-26-gb76a