Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
Commitdd31874f717a371b207d9e27e178e9f005795c52 (patch)
Author
 Syndamia <kamen@syndamia.com>
2023-03-28 12:34:45 +0300
Committer
 Syndamia <kamen@syndamia.com>
2023-03-28 12:34:45 +0300
Filesa4b1715a2c26d44f75d7e8c88e3efab2a5803484
syndamia.com-dd31874f717a371b207d9e27e178e9f005795c52.tar
syndamia.com-dd31874f717a371b207d9e27e178e9f005795c52.tar.gz
syndamia.com-dd31874f717a371b207d9e27e178e9f005795c52.zip
Parentda9cc67e70a60b6eff4e685e1b9df1b6e71f1d3c (diff)
[tutorials/ctmide] Updated code blocks to be proper markdown ones
1 files changed, 17 insertions, 14 deletions
-rw-r--r--src/tutorials/connect-to-mysql-in-dotnet-ef/index.md31
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 d6bde42..c5f0e9d 100644
--- a/src/tutorials/connect-to-mysql-in-dotnet-ef/index.md
+++ b/src/tutorials/connect-to-mysql-in-dotnet-ef/index.md
@@ -39,8 +39,9 @@ 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:
-<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>
+```csharp
+.UseMySql(CONNECTION_STRING, new MySqlServerVersion(new System.Version(8, 0, 21)))
+```
Where `CONNECTION_STRING` is a (constant) variable that contains your connection string, and 8, 0, 21 are the version numbers.
@@ -50,23 +51,25 @@ For `ASP.NET` applications, the connection must be put inside the `ConfigureServ
The result should look something along the lines of:
-<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)
-{
- <span class="com">...</span>
- services.<span class="fnc">AddDbContext</span>&lt;<span class="cls">AppDbContext</span>&gt;(opt =&gt;
+```csharp
+// This method gets called by the runtime. Use this method to add services to the container.
+public void ConfigureServices(IServiceCollection services)
+{
+ ...
+ services.AddDbContext<AppDbContext>(opt =>
{
- opt.<span class="fnc">UseMySql</span>(<span class="com">...</span>);
+ opt.UseMySql(...);
});
-}</code></pre>
-<p></p>
+}
+```
### 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.
-<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)
+```csharp
+protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
- optionsBuilder.<span class="fnc">UseMySql</span>(<span class="com">...</span>);
-}</code></pre>
-<p></p>
+ optionsBuilder.UseMySql(...);
+}
+```