title: Asp.Net Core - The configured user limit (128) on the number of inotify instances has been reached
body: <p>the <strong>asp.net core MVC</strong> report error after certain times of query to the mysql database (on <strong>Ubuntu 14.04/16.04</strong>) with the following message:
  "<strong>The configured user limit (128) on the number of inotify instances has been reached.</strong>"
  It can be identified that the error was raised because of the controller opened too many files and exceeded the limits of iNotify setting (in the <strong>/proc/sys/fs/inotify/max_user_instances</strong>). But I was just baffled when the ASP.NET opened files on each http request and why it doesn't close the file properly? Any one encounted this issue too?
  Remarks: I was using Mysql.data.core and mysql.data.entityframeworkcore provider.</p>
  
  <pre><code>    private static string classiferstring = "sports,outdoor,startup,pets,child,adult,elderly";
  
      [AllowAnonymous]
      [HttpGet]
      public async Task&lt;object&gt; Classify([FromQuery] string classifyword)
      {
          string[] classifers = classiferstring.Split(',');
          if (!classifers.Contains(classifyword))
          {
              return new
              {
                  status = 0,
                  info = "WrongClassifier",
                  Data = ""
              };
          }
  
          try
          {
              var predata = await (from d in _context.descriptor
                                join a in _context.combination on d.ID equals a.ID
                                select new ProductsVM
                                {
                                    CREATETIME = a.CREATETIME,
                                    ID = a.ID,
                                    COMPANY = a.COMPANY,
                                    NAME = a.NAME,
                                    PRICE = a.PRICE,
                                    TYPE = a.TYPE,
                                    HEADPHOTO = a.HEADPHOTO,
                                    REMARK = a.REMARK,
  
                                    Tags = d.Tags,
                                    Classifier = d.Classifier,
                                    OriginName = d.OriginName,
                                    Briefing = d.Briefing
                                }).ToListAsync();
              var data = (from x in predata
                            where x.Classifier.Contains(classifyword.ToLower())
                            select x).ToList();
  
              if(predata.Count&lt;=0)
              {
                  return new
                  {
                      status = 2,
                      info = "NoResult",
                      Data = ""
                  };
              }else
              {
                  return new
                  {
                      status = 1,
                      info = "Success",
                      Data = data
                  };
              };
          }
          catch(Exception e)
          {
              return new
              {
                  status = 0,
                  info = "Error",
                  Data = e.Message
              };
          }
      }
  </code></pre>
  
  <p>Please notice the exception was raised only in the try/catch code block instead of immediately after the action is invokded.</p>
  
  <p>Many thanks if anyone has some clue to resolve this problem.</p>