• <legend id='MG39U'><style id='MG39U'><dir id='MG39U'><q id='MG39U'></q></dir></style></legend><tfoot id='MG39U'></tfoot>

    <small id='MG39U'></small><noframes id='MG39U'>

        <bdo id='MG39U'></bdo><ul id='MG39U'></ul>

      1. <i id='MG39U'><tr id='MG39U'><dt id='MG39U'><q id='MG39U'><span id='MG39U'><b id='MG39U'><form id='MG39U'><ins id='MG39U'></ins><ul id='MG39U'></ul><sub id='MG39U'></sub></form><legend id='MG39U'></legend><bdo id='MG39U'><pre id='MG39U'><center id='MG39U'></center></pre></bdo></b><th id='MG39U'></th></span></q></dt></tr></i><div id='MG39U'><tfoot id='MG39U'></tfoot><dl id='MG39U'><fieldset id='MG39U'></fieldset></dl></div>
      2. .net core 2.1 MVC for MySQL 数据库中的瞬时故障处理

        Transient Failure handling in .net core 2.1 MVC for MySQL Database(.net core 2.1 MVC for MySQL 数据库中的瞬时故障处理)
        1. <small id='wZFtw'></small><noframes id='wZFtw'>

          • <legend id='wZFtw'><style id='wZFtw'><dir id='wZFtw'><q id='wZFtw'></q></dir></style></legend>
              <bdo id='wZFtw'></bdo><ul id='wZFtw'></ul>

              <i id='wZFtw'><tr id='wZFtw'><dt id='wZFtw'><q id='wZFtw'><span id='wZFtw'><b id='wZFtw'><form id='wZFtw'><ins id='wZFtw'></ins><ul id='wZFtw'></ul><sub id='wZFtw'></sub></form><legend id='wZFtw'></legend><bdo id='wZFtw'><pre id='wZFtw'><center id='wZFtw'></center></pre></bdo></b><th id='wZFtw'></th></span></q></dt></tr></i><div id='wZFtw'><tfoot id='wZFtw'></tfoot><dl id='wZFtw'><fieldset id='wZFtw'></fieldset></dl></div>

                  <tbody id='wZFtw'></tbody>
                  <tfoot id='wZFtw'></tfoot>
                  本文介绍了.net core 2.1 MVC for MySQL 数据库中的瞬时故障处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  services.AddDbContext(options =>{options.UseSqlServer(mysqlConnection,sqlServerOptionsAction: sqlOptions =>{sqlOptions.EnableRetryOnFailure(maxRetryCount: 10,maxRetryDelay: TimeSpan.FromSeconds(30),errorNumbersToAdd: null);});});

                  我在以下位置找到了此代码片段:

                  这意味着 EnableRetryOnFailure 不适用于 MySQL 数据库.我现在如何设置重试、延迟等政策?

                  另外,如果我尝试设置 ExecutionStrategy 函数,我会得到这个:

                  然后我尝试使用以下方法创建自己的策略:

                  公共类MyStrategy:ExecutionStrategy{......}

                  但是现在如何使用这个类?

                  解决方案

                  有一个用于此的库:https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql

                  设置步骤:

                  1. 从 NuGet 下载 Pomelo.EntityFrameworkCore.MySql.

                  2. 将此使用添加到您的类:

                    使用 Pomelo.EntityFrameworkCore.MySql.Infrastructure;

                  3. 将此添加到您的 ConfigureServices 方法中:

                    services.AddDbContextPool(选项 =>options.UseMySql("Server=localhost;Database=ef;User=root;Password=123456;",mySqlOptions =>{mySqlOptions.ServerVersion(新版本(5, 7, 17), ServerType.MySql).EnableRetryOnFailure(maxRetryCount: 10,maxRetryDelay: TimeSpan.FromSeconds(30),errorNumbersToAdd: null);}));

                  services.AddDbContext<MyContext>(options =>
                  {
                      options.UseSqlServer(mysqlConnection,
                      sqlServerOptionsAction: sqlOptions =>
                      {
                          sqlOptions.EnableRetryOnFailure(
                          maxRetryCount: 10,
                          maxRetryDelay: TimeSpan.FromSeconds(30),
                          errorNumbersToAdd: null);
                      });
                  });
                  

                  I found this code snippet at:

                  https://docs.microsoft.com/en-us/dotnet/standard/microservices-architecture/implement-resilient-applications/implement-resilient-entity-framework-core-sql-connections

                  My DB is MySQL 5.7

                  I changed the above code to :

                  That means EnableRetryOnFailure is not available for MySQL DB. How do i set the retry, delay etc.. policies now?

                  Also if i try to set the ExecutionStrategy function i get this:

                  Then i tried Create my own Strategy using:

                  public class MyStrategy: ExecutionStrategy
                  {
                     ......
                  }
                  

                  but how to use this class now?

                  解决方案

                  There is a library for this: https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql

                  Setup steps:

                  1. Donwload Pomelo.EntityFrameworkCore.MySql from NuGet.

                  2. Add this using to your class:

                    using Pomelo.EntityFrameworkCore.MySql.Infrastructure;

                  3. Add this to your ConfigureServices method:

                    services.AddDbContextPool<ApplicationDbContext>( 
                    options => options.UseMySql("Server=localhost;Database=ef;User=root;Password=123456;",
                    
                        mySqlOptions =>
                        {
                            mySqlOptions.ServerVersion(new Version(5, 7, 17), ServerType.MySql)
                            .EnableRetryOnFailure(
                            maxRetryCount: 10,
                            maxRetryDelay: TimeSpan.FromSeconds(30),
                            errorNumbersToAdd: null); 
                        }
                    ));
                    

                  这篇关于.net core 2.1 MVC for MySQL 数据库中的瞬时故障处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to delete duplicate records in mysql database?(如何删除mysql数据库中的重复记录?)
                  Python Pandas write to sql with NaN values(Python Pandas 使用 NaN 值写入 sql)
                  MySQL Insert amp; Joins(MySQL 插入 amp;加入)
                  MySQL concat() to create column names to be used in a query?(MySQL concat() 创建要在查询中使用的列名?)
                  NodeJS responded MySQL timezone is different when I fetch directly from MySQL(当我直接从 MySQL 获取时,NodeJS 响应 MySQL 时区不同)
                  WHERE datetime older than some time (eg. 15 minutes)(WHERE 日期时间早于某个时间(例如 15 分钟))
                  1. <i id='RUtWa'><tr id='RUtWa'><dt id='RUtWa'><q id='RUtWa'><span id='RUtWa'><b id='RUtWa'><form id='RUtWa'><ins id='RUtWa'></ins><ul id='RUtWa'></ul><sub id='RUtWa'></sub></form><legend id='RUtWa'></legend><bdo id='RUtWa'><pre id='RUtWa'><center id='RUtWa'></center></pre></bdo></b><th id='RUtWa'></th></span></q></dt></tr></i><div id='RUtWa'><tfoot id='RUtWa'></tfoot><dl id='RUtWa'><fieldset id='RUtWa'></fieldset></dl></div>

                      <bdo id='RUtWa'></bdo><ul id='RUtWa'></ul>

                    • <tfoot id='RUtWa'></tfoot>

                          <small id='RUtWa'></small><noframes id='RUtWa'>

                          • <legend id='RUtWa'><style id='RUtWa'><dir id='RUtWa'><q id='RUtWa'></q></dir></style></legend>
                              <tbody id='RUtWa'></tbody>