title: How to use try-catch block to connect to the Entity Framework?
body: <p>I am a new ASP.NET developer and this is my first time to use Linq-to-Entities and Entity Framework. My problem now is about using the best practice of connecting to the Entities or Database. I know that try-catch block is very expensive. But should I use them whenever I need to connect to the database? I am asking this question because I have around 20 entities and in my Data Access Layer, I have all the GetData() methods for each one of these entities. Could you please advise on this?</p>
  
  <p>C# code:</p>
  
  <pre><code>public static IEnumerable&lt;Items&gt; getData()
  {
      List&lt;Items&gt; itemsList = new List&lt;Items&gt;();
      try
      {
          using (ItemsDBEntities context = new ItemsDBEntities())
          {
              itemsList = (from item in context.Items
                           select new Items()
                           {
                               ID = item.ID,
                               Code = item.Code,
                               Name = item.Name,
                               StatusID = item.StatusID
                           }).ToList();
          }
      }
      catch (EntityException ex)
      {
          //something wrong about entity
      }
      catch (Exception ex)
      {
          //Don't know what happend... 
      }
      return itemsList;
  }
  </code></pre>