Summary Files Commits Branches @commit @diff @stats
path: root / src / tutorials
diff options
context:
space:
mode:
Commit46f51427c86ad8cb0f695adcd6c93a7a29a8f496 (patch)
Author
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-02-17 17:12:31 +0200
Committer
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-02-17 17:12:31 +0200
Files3b0a1ff5a9595b37ea94c1d5d6d32a43c40b3081 /src/tutorials
syndamia.com-46f51427c86ad8cb0f695adcd6c93a7a29a8f496.tar
syndamia.com-46f51427c86ad8cb0f695adcd6c93a7a29a8f496.tar.gz
syndamia.com-46f51427c86ad8cb0f695adcd6c93a7a29a8f496.zip
Parentb72cfed979a1c99fdcfbdd25c709a5806c7db221 (diff)
Added "syntax highlighting" styling and implemented it in the connect to mysql article
1 files changed, 13 insertions, 18 deletions
-rw-r--r--src/tutorials/connect-to-mysql-in-dotnet-ef/article.md31
diff --git a/src/tutorials/connect-to-mysql-in-dotnet-ef/article.md b/src/tutorials/connect-to-mysql-in-dotnet-ef/article.md
index 775bab1..4b3a5da 100644
--- a/src/tutorials/connect-to-mysql-in-dotnet-ef/article.md
+++ b/src/tutorials/connect-to-mysql-in-dotnet-ef/article.md
@@ -50,9 +50,8 @@ The method requires at least two arguments: connection string and `MySql` server
For the server version argument, create a new object of type `MySqlServerVersion` and give it's constructor a new object of type `Version`, to which you give the version numbers. The result should look something like this:
-```
-.UseMySql(CONNECTION_STRING, new MySqlServerVersion(new System.Version(8, 0, 21)))
-```
+<pre><code>.<span class="fnc">UseMySql</span>(CONNECTION_STRING, <span class="kwd">new</span> <span class="cls">MySqlServerVersion</span>(<span class="kwd">new</span> <span class="kwD">System</span>.<span class="cls">Version</span>(<span class="cst">8</span>, <span class="cst">0</span>, <span class="cst">21</span>)))
+</code></pre>
Where `CONNECTION_STRING` is a (constant) variable that contains your connection string, and 8, 0, 21 are the version numbers.
@@ -63,17 +62,15 @@ For `ASP.NET` applications, the connection must be put inside the `ConfigureServ
The result should look something along the lines of:
-```
-// This method gets called by the runtime. Use this method to add services to the container.
-public void ConfigureServices(IServiceCollection services)
+<pre><code><span class="com">// This method gets called by the runtime. Use this method to add services to the container.</span>
+<span class="kwd">public</span> <span class="typ">void</span> <span class="fnc">ConfigureServices</span>(<span class="cls">IServiceCollection</span> services)
{
- ...
- services.AddDbContext<AppDbContext>(opt =>
- {
- opt.UseMySql(...);
- });
-}
-```
+ <span class="com">...</span>
+ services.<span class="fnc">AddDbContext</span>&lt;<span class="cls">AppDbContext</span>&gt;(opt =&gt;
+ {
+ opt.<span class="fnc">UseMySql</span>(<span class="com">...</span>);
+ });
+}</code></pre>
<p></p>
### DBContext child class
@@ -81,10 +78,8 @@ public void ConfigureServices(IServiceCollection services)
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.
-```
-protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
+<pre><code><span class="kwd">protected</span> <span class="kwd">override</span> <span class="typ">void</span> <span class="fnc">OnConfiguring</span>(<span class="cls">DbContextOptionsBuilder</span> optionsBuilder)
{
- optionsBuilder.UseMySql(...);
-}
-```
+ optionsBuilder.<span class="fnc">UseMySql</span>(<span class="com">...</span>);
+}</code></pre>
<p></p>