title: Why can't I call my WriteLogDataToDb method?
body: <p>I'm making a user inactivity logger for an internal application at work, and I'm having trouble writing consumed messages to a MySQL database, when I try to call my method that writes the messages to the database, it throws an error:   'AccessEye.LogData' is a 'type', which is not valid in the given context    </p>
  
  <p>Any and all help with this would be appreciated, it's a windows forms project with a topshelf service being used as the RabbitMQ Consumer, which will eventually forward messages to the database as mentioned =]</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Diagnostics;
  using NLog;
  using IWshRuntimeLibrary;
  using Topshelf;
  using System.Data.Odbc;
  using EasyNetQ;
  using RabbitMQ;
  using EasyNetQ.Topology;
  using System.Threading.Tasks;
  using System.Windows.Forms;
  using AccessEye;
  using System.ComponentModel;
  
  namespace LogService
  {
      public class WindowsServiceHost : ServiceControl, ServiceShutdown
      {
          public static readonly Logger Logger = LogManager.GetCurrentClassLogger();
  
          public static void WriteLogDataToDb(LogData data)
          {
              using (var db = new LogService.UserActivityDataContext())
              {
                  DbLogData logData = AutoMapper.Mapper.Map&lt;LogData, DbLogData&gt;(data);
  
                  int t = (int)data.EventType;
  
                  EventType eventType = db.EventTypes.FirstOrDefault(r =&gt; r.Id == t);
  
                  if (eventType == null)
                  {
                      eventType = db.EventTypes.Add(new EventType
                      {
                          Event = GetEnumDescriptionAttributeValue(data.EventType),
                          Id = (int)data.EventType
                      });
                      db.SaveChanges();
                  }
  
                  logData.EventTypeId = eventType.Id;
                  db.LogEvents.Add(logData);
  
                  db.SaveChanges();
              }
          }
  
          public static string GetEnumDescriptionAttributeValue(Enum value)
          {
              var fieldInfo = value.GetType().GetField(value.ToString());
              var attributes = (DescriptionAttribute[])fieldInfo.GetCustomAttributes(typeof(DescriptionAttribute), false);
              return attributes.Length &gt; 0 ? attributes[0].Description : value.ToString();
          }
  
          public bool Start(HostControl hostControl)
          {
              Program.bus = RabbitHutch.CreateBus("host=as01.access.local;virtualHost=DEV-Reece;username=reece;password=reece").Advanced;
  
              //var bus = RabbitHutch.CreateBus("host=as01.access.local;virtualHost=DEV-Reece;username=reece;password=reece").Advanced;
              var queue = Queue.Declare(true, false, true, null);
              var exchange = Exchange.DeclareFanout("UserActivityFanout", true, false, null);
              var exchangeTopic = Exchange.DeclareTopic("UserActivity", true, false, null);
              queue.BindTo(exchange, "#");
              exchange.BindTo(exchangeTopic, "#");
              Program.bus.Subscribe&lt;AccessEye.LogData&gt;(queue, (msg, messageRecInfo) =&gt; Task.Factory.StartNew(() =&gt;
              {
                  WriteLogDataToDb(AccessEye.LogData);
  
                  //AppForm.WriteLogDataToDb(data);
                  //Console.WriteLine(msg.Body.UserName + " -- " + msg.Body.ComputerName + " -- " + msg.Body.EventType + " -- " + msg.Body.TeamviewerId);
              }));
  
              return true;    
          }
  
          public bool Stop(HostControl hostControl)
          {
              Logger.Trace("STOP");
              Program.bus.Dispose();
              return true;
          }
  
          public void Shutdown(HostControl hostControl)
          {
              Logger.Trace("SHUTDOWN");
              Program.bus.Dispose();
  
          }
      }
  }
  </code></pre>