title: type used in a using statement must be implicity convertible to system.Idisposable
body: <p>Started a new mvc4 project. Used the MVC controller template to create the read/write actions of the <code>'Orders'</code> Model. Added a new Entity framework connection to my db and am attempting to update it with a new order.</p>
  
  <pre><code>[HttpPost]
      public ActionResult Create(Orders orders)
      {
          try
          {
  
              //type used in a using statement must be implicity convertible to system.Idisposable
              using (BuyABicycleEntities db = new BuyABicycleEntities())
              {
                  Order NewOrder = new Order();
                  NewOrder.BicycleColour = orders.BicycleColour;
                  NewOrder.BicycleModel = orders.BicycleModel;
                  NewOrder.BicycleSize = orders.BicycleSize;
                  NewOrder.CustomerAddress = orders.CustomerAddress;
                  NewOrder.CustomerEmail = orders.CustomerEmail;
                  NewOrder.CustomerName = orders.CustomerName;
                  NewOrder.CustomerPhoneNumber = orders.CustomerPhoneNumber;
  
                  //entiry framework new item
                  //db.Orders.(NewOrder);
                  db.SaveChanges();
  
              }
  
              return View(orders);
          }
          catch (Exception ex)
          {
              //Show Message("Error in Orders - " + ex.Message);
  
          }
      }
  </code></pre>
  
  <p>however the using statement is flagging an error: </p>
  
  <blockquote>
    <p>type used in a using statement must be implicity convertible to
    system.Idisposable</p>
  </blockquote>
  
  <p>So I have to implement an <code>idisposable</code>?, will I have to do this everytime I want to update the db? Searched through stackoverflow alot of similar Q's but still unsure as to how to dispose of mine? please advise. thanks</p>
  
  <pre><code>    // ------------------------------------------------------------------------------
  // DO NOT MODIFY THIS CLASS - AutoGenerated Code
  //    Any changes made to this code will be lost the next time this 
  //    code is regenerated.
  // 
  //    Generated at: 05/08/2014 14:16:31
  //    DevForce version: 6.1.7.0
  //    Template version: 2.1.4
  // ------------------------------------------------------------------------------
  using System;
  using System.ComponentModel;
  using System.ComponentModel.DataAnnotations;
  using System.Linq;
  using System.Runtime.Serialization;
  using IbEm   = IdeaBlade.EntityModel;
  using IbCore = IdeaBlade.Core;
  using IbVal  = IdeaBlade.Validation;
  
  [module: IbCore.IdeaBladeLicense("5w+U/Qneh0KYrGDaCOhKKqJpzM0BhW5i7ky77IZpGawLem2DQ5JuP6W8fhhcpF/x")]
  
  namespace MvcApplication18 { 
  
    #region BuyABicycleEntities
  
    /// &lt;summary&gt;
    /// The domain-specific EntityManager for your domain model.
    /// &lt;/summary&gt;
    public partial class BuyABicycleEntities : IbEm.EntityManager {
  
      #region Constructors
  
      /// &lt;summary&gt;See &lt;see cref="M:IbEm.EntityManager.#ctor(bool, string, IbEm.EntityServiceOption, string)"/&gt;. &lt;/summary&gt;
      public BuyABicycleEntities(bool shouldConnect=true, string dataSourceExtension=null, IbEm.EntityServiceOption entityServiceOption=IbEm.EntityServiceOption.UseDefaultService, string compositionContextName=null) : base(shouldConnect, dataSourceExtension, entityServiceOption, compositionContextName) {}
  
      /// &lt;summary&gt;See &lt;see cref="M:IbEm.EntityManager.#ctor(IbEm.EntityManagerContext)"/&gt;. &lt;/summary&gt;
      public BuyABicycleEntities(IbEm.EntityManagerContext entityManagerContext) : base(entityManagerContext) {}
  
      /// &lt;summary&gt;See &lt;see cref="M:IbEm.EntityManager.#ctor(IbEm.EntityManager, bool, string, IbEm.EntityServiceOption, string)"/&gt;. &lt;/summary&gt;
      public BuyABicycleEntities(IbEm.EntityManager entityManager, bool shouldConnect, string dataSourceExtension=null, IbEm.EntityServiceOption entityServiceOption=IbEm.EntityServiceOption.UseDefaultService, string compositionContextName=null) : base(entityManager, shouldConnect, dataSourceExtension, entityServiceOption, compositionContextName) {}
  
      /// &lt;summary&gt;See &lt;see cref="M:IbEm.EntityManager.#ctor(IbEm.EntityManager, IbEm.EntityManagerContext)"/&gt;. &lt;/summary&gt;
      public BuyABicycleEntities(IbEm.EntityManager entityManager, IbEm.EntityManagerContext entityManagerContext=null) : base(entityManager, entityManagerContext) {}
  
      static BuyABicycleEntities() {
        IbEm.EntityRelation.InitializeEntityRelations(System.Reflection.Assembly.GetExecutingAssembly());
      }
      #endregion Constructors
  
      #region EntityQueries
  
      /// &lt;summary&gt;Gets the &lt;see cref="T:IbEm.EntityQuery"/&gt; associated with the given EntitySet name. &lt;/summary&gt;
      public IbEm.EntityQuery&lt;BicycleModel&gt; BicycleModels {
        get { return new IbEm.EntityQuery&lt;BicycleModel&gt;("BicycleModels", this); }
      }
  
      /// &lt;summary&gt;Gets the &lt;see cref="T:IbEm.EntityQuery"/&gt; associated with the given EntitySet name. &lt;/summary&gt;
      public IbEm.EntityQuery&lt;Customer&gt; Customers {
        get { return new IbEm.EntityQuery&lt;Customer&gt;("Customers", this); }
      }
  
      /// &lt;summary&gt;Gets the &lt;see cref="T:IbEm.EntityQuery"/&gt; associated with the given EntitySet name. &lt;/summary&gt;
      public IbEm.EntityQuery&lt;Order&gt; Orders {
        get { return new IbEm.EntityQuery&lt;Order&gt;("Orders", this); }
      }
      #endregion EntityQueries
    }
    #endregion BuyABicycleEntities
  
    #region BicycleModel class
  
    /// &lt;summary&gt;The auto-generated BicycleModel class. &lt;/summary&gt;
    [DataContract(IsReference=true)]
    [IbEm.DataSourceKeyName(@"BuyABicycleEntities")]
    [IbEm.DefaultEntitySetName(@"BuyABicycleEntities.BicycleModels")]
    public partial class BicycleModel : IbEm.Entity {
  
      /// &lt;summary&gt;Returns the property path for the given expression. &lt;/summary&gt;
      /// &lt;example&gt;
      /// Usage:
      /// &lt;code&gt;
      ///    var r = Employee.PathFor(e =&gt; e.Manager.City); // returns "Manager.City"
      /// &lt;/code&gt;
      /// &lt;/example&gt;
      public static string PathFor(System.Linq.Expressions.Expression&lt;System.Func&lt;BicycleModel, object&gt;&gt; expr) {
        return IbCore.PropertyPath.For&lt;BicycleModel&gt;(expr);
      }
  
      #region Data Properties
  
      /// &lt;summary&gt;Gets or sets the Id. &lt;/summary&gt;
      [Key]
      [DataMember]
      [Bindable(true, BindingDirection.TwoWay)]
      [Editable(true)]
      [Display(Name="Id", AutoGenerateField=true)]
      [IbVal.RequiredValueVerifier( ErrorMessageResourceName="BicycleModel_Id")]
      public int Id {
        get { return PropertyMetadata.Id.GetValue(this); }
        set { PropertyMetadata.Id.SetValue(this, value); }
      }
  
      /// &lt;summary&gt;Gets or sets the ModelName. &lt;/summary&gt;
      [DataMember]
      [Bindable(true, BindingDirection.TwoWay)]
      [Editable(true)]
      [Display(Name="ModelName", AutoGenerateField=true)]
      [IbVal.StringLengthVerifier(MaxValue=50, IsRequired=true, ErrorMessageResourceName="BicycleModel_ModelName")]
      public string ModelName {
        get { return PropertyMetadata.ModelName.GetValue(this); }
        set { PropertyMetadata.ModelName.SetValue(this, value); }
      }
      #endregion Data Properties
  
      #region Navigation properties
      #endregion Navigation properties
  
      #region EntityProperty definitions
      public partial class PropertyMetadata {
  
        /// Explicit static constructor ensures static fields are initialized.
        static PropertyMetadata() {}
  
        /// &lt;summary&gt;The Id &lt;see cref="T:IbEm.DataEntityProperty"/&gt;. &lt;/summary&gt;
        public static readonly IbEm.DataEntityProperty&lt;BicycleModel, int&gt; Id = new IbEm.DataEntityProperty&lt;BicycleModel, int&gt;("Id", false, true, IbEm.ConcurrencyStrategy.None, true, null);
  
        /// &lt;summary&gt;The ModelName &lt;see cref="T:IbEm.DataEntityProperty"/&gt;. &lt;/summary&gt;
        public static readonly IbEm.DataEntityProperty&lt;BicycleModel, string&gt; ModelName = new IbEm.DataEntityProperty&lt;BicycleModel, string&gt;("ModelName", false, false, IbEm.ConcurrencyStrategy.None, false, null);
      }
      #endregion EntityProperty definitions
  
      #region EntityPropertyNames
      public new partial class EntityPropertyNames : IbEm.Entity.EntityPropertyNames {
        public const String Id = "Id";
        public const String ModelName = "ModelName";
      }
      #endregion EntityPropertyNames
    }
    #endregion BicycleModel class
  
    #region Customer class
  
    /// &lt;summary&gt;The auto-generated Customer class. &lt;/summary&gt;
    [DataContract(IsReference=true)]
    [IbEm.DataSourceKeyName(@"BuyABicycleEntities")]
    [IbEm.DefaultEntitySetName(@"BuyABicycleEntities.Customers")]
    public partial class Customer : IbEm.Entity {
  
      /// &lt;summary&gt;Returns the property path for the given expression. &lt;/summary&gt;
      /// &lt;example&gt;
      /// Usage:
      /// &lt;code&gt;
      ///    var r = Employee.PathFor(e =&gt; e.Manager.City); // returns "Manager.City"
      /// &lt;/code&gt;
      /// &lt;/example&gt;
      public static string PathFor(System.Linq.Expressions.Expression&lt;System.Func&lt;Customer, object&gt;&gt; expr) {
        return IbCore.PropertyPath.For&lt;Customer&gt;(expr);
      }
  
      #region Data Properties
  
      /// &lt;summary&gt;Gets or sets the Id. &lt;/summary&gt;
      [Key]
      [DataMember]
      [Bindable(true, BindingDirection.TwoWay)]
      [Editable(true)]
      [Display(Name="Id", AutoGenerateField=true)]
      [IbVal.RequiredValueVerifier( ErrorMessageResourceName="Customer_Id")]
      public int Id {
        get { return PropertyMetadata.Id.GetValue(this); }
        set { PropertyMetadata.Id.SetValue(this, value); }
      }
  
      /// &lt;summary&gt;Gets or sets the CustomerName. &lt;/summary&gt;
      [DataMember]
      [Bindable(true, BindingDirection.TwoWay)]
      [Editable(true)]
      [Display(Name="CustomerName", AutoGenerateField=true)]
      [IbVal.StringLengthVerifier(MaxValue=50, IsRequired=true, ErrorMessageResourceName="Customer_CustomerName")]
      public string CustomerName {
        get { return PropertyMetadata.CustomerName.GetValue(this); }
        set { PropertyMetadata.CustomerName.SetValue(this, value); }
      }
      #endregion Data Properties
  
      #region Navigation properties
      #endregion Navigation properties
  
      #region EntityProperty definitions
      public partial class PropertyMetadata {
  
        /// Explicit static constructor ensures static fields are initialized.
        static PropertyMetadata() {}
  
        /// &lt;summary&gt;The Id &lt;see cref="T:IbEm.DataEntityProperty"/&gt;. &lt;/summary&gt;
        public static readonly IbEm.DataEntityProperty&lt;Customer, int&gt; Id = new IbEm.DataEntityProperty&lt;Customer, int&gt;("Id", false, true, IbEm.ConcurrencyStrategy.None, true, null);
  
        /// &lt;summary&gt;The CustomerName &lt;see cref="T:IbEm.DataEntityProperty"/&gt;. &lt;/summary&gt;
        public static readonly IbEm.DataEntityProperty&lt;Customer, string&gt; CustomerName = new IbEm.DataEntityProperty&lt;Customer, string&gt;("CustomerName", false, false, IbEm.ConcurrencyStrategy.None, false, null);
      }
      #endregion EntityProperty definitions
  
      #region EntityPropertyNames
      public new partial class EntityPropertyNames : IbEm.Entity.EntityPropertyNames {
        public const String Id = "Id";
        public const String CustomerName = "CustomerName";
      }
      #endregion EntityPropertyNames
    }
    #endregion Customer class
  
    #region Order class
  
    /// &lt;summary&gt;The auto-generated Order class. &lt;/summary&gt;
    [DataContract(IsReference=true)]
    [IbEm.DataSourceKeyName(@"BuyABicycleEntities")]
    [IbEm.DefaultEntitySetName(@"BuyABicycleEntities.Orders")]
    public partial class Order : IbEm.Entity {
  
      /// &lt;summary&gt;Returns the property path for the given expression. &lt;/summary&gt;
      /// &lt;example&gt;
      /// Usage:
      /// &lt;code&gt;
      ///    var r = Employee.PathFor(e =&gt; e.Manager.City); // returns "Manager.City"
      /// &lt;/code&gt;
      /// &lt;/example&gt;
      public static string PathFor(System.Linq.Expressions.Expression&lt;System.Func&lt;Order, object&gt;&gt; expr) {
        return IbCore.PropertyPath.For&lt;Order&gt;(expr);
      }
  
      #region Data Properties
  
      /// &lt;summary&gt;Gets or sets the Id. &lt;/summary&gt;
      [Key]
      [DataMember]
      [Bindable(true, BindingDirection.TwoWay)]
      [Editable(true)]
      [Display(Name="Id", AutoGenerateField=true)]
      [IbVal.RequiredValueVerifier( ErrorMessageResourceName="Order_Id")]
      public int Id {
        get { return PropertyMetadata.Id.GetValue(this); }
        set { PropertyMetadata.Id.SetValue(this, value); }
      }
  
      /// &lt;summary&gt;Gets or sets the CustomerName. &lt;/summary&gt;
      [DataMember]
      [Bindable(true, BindingDirection.TwoWay)]
      [Editable(true)]
      [Display(Name="CustomerName", AutoGenerateField=true)]
      [IbVal.StringLengthVerifier(MaxValue=50, IsRequired=true, ErrorMessageResourceName="Order_CustomerName")]
      public string CustomerName {
        get { return PropertyMetadata.CustomerName.GetValue(this); }
        set { PropertyMetadata.CustomerName.SetValue(this, value); }
      }
  
      /// &lt;summary&gt;Gets or sets the CustomerAddress. &lt;/summary&gt;
      [DataMember]
      [Bindable(true, BindingDirection.TwoWay)]
      [Editable(true)]
      [Display(Name="CustomerAddress", AutoGenerateField=true)]
      [IbVal.StringLengthVerifier(MaxValue=50, IsRequired=true, ErrorMessageResourceName="Order_CustomerAddress")]
      public string CustomerAddress {
        get { return PropertyMetadata.CustomerAddress.GetValue(this); }
        set { PropertyMetadata.CustomerAddress.SetValue(this, value); }
      }
  
      /// &lt;summary&gt;Gets or sets the CustomerPhoneNumber. &lt;/summary&gt;
      [DataMember]
      [Bindable(true, BindingDirection.TwoWay)]
      [Editable(true)]
      [Display(Name="CustomerPhoneNumber", AutoGenerateField=true)]
      [IbVal.StringLengthVerifier(MaxValue=50, IsRequired=true, ErrorMessageResourceName="Order_CustomerPhoneNumber")]
      public string CustomerPhoneNumber {
        get { return PropertyMetadata.CustomerPhoneNumber.GetValue(this); }
        set { PropertyMetadata.CustomerPhoneNumber.SetValue(this, value); }
      }
  
      /// &lt;summary&gt;Gets or sets the CustomerEmail. &lt;/summary&gt;
      [DataMember]
      [Bindable(true, BindingDirection.TwoWay)]
      [Editable(true)]
      [Display(Name="CustomerEmail", AutoGenerateField=true)]
      [IbVal.StringLengthVerifier(MaxValue=50, IsRequired=true, ErrorMessageResourceName="Order_CustomerEmail")]
      public string CustomerEmail {
        get { return PropertyMetadata.CustomerEmail.GetValue(this); }
        set { PropertyMetadata.CustomerEmail.SetValue(this, value); }
      }
  
      /// &lt;summary&gt;Gets or sets the BicycleModel. &lt;/summary&gt;
      [DataMember]
      [Bindable(true, BindingDirection.TwoWay)]
      [Editable(true)]
      [Display(Name="BicycleModel", AutoGenerateField=true)]
      [IbVal.StringLengthVerifier(MaxValue=50, IsRequired=true, ErrorMessageResourceName="Order_BicycleModel")]
      public string BicycleModel {
        get { return PropertyMetadata.BicycleModel.GetValue(this); }
        set { PropertyMetadata.BicycleModel.SetValue(this, value); }
      }
  
      /// &lt;summary&gt;Gets or sets the BicycleSize. &lt;/summary&gt;
      [DataMember]
      [Bindable(true, BindingDirection.TwoWay)]
      [Editable(true)]
      [Display(Name="BicycleSize", AutoGenerateField=true)]
      [IbVal.StringLengthVerifier(MaxValue=50, IsRequired=true, ErrorMessageResourceName="Order_BicycleSize")]
      public string BicycleSize {
        get { return PropertyMetadata.BicycleSize.GetValue(this); }
        set { PropertyMetadata.BicycleSize.SetValue(this, value); }
      }
  
      /// &lt;summary&gt;Gets or sets the BicycleColour. &lt;/summary&gt;
      [DataMember]
      [Bindable(true, BindingDirection.TwoWay)]
      [Editable(true)]
      [Display(Name="BicycleColour", AutoGenerateField=true)]
      [IbVal.StringLengthVerifier(MaxValue=50, IsRequired=true, ErrorMessageResourceName="Order_BicycleColour")]
      public string BicycleColour {
        get { return PropertyMetadata.BicycleColour.GetValue(this); }
        set { PropertyMetadata.BicycleColour.SetValue(this, value); }
      }
      #endregion Data Properties
  
      #region Navigation properties
      #endregion Navigation properties
  
      #region EntityProperty definitions
      public partial class PropertyMetadata {
  
        /// Explicit static constructor ensures static fields are initialized.
        static PropertyMetadata() {}
  
        /// &lt;summary&gt;The Id &lt;see cref="T:IbEm.DataEntityProperty"/&gt;. &lt;/summary&gt;
        public static readonly IbEm.DataEntityProperty&lt;Order, int&gt; Id = new IbEm.DataEntityProperty&lt;Order, int&gt;("Id", false, true, IbEm.ConcurrencyStrategy.None, true, null);
  
        /// &lt;summary&gt;The CustomerName &lt;see cref="T:IbEm.DataEntityProperty"/&gt;. &lt;/summary&gt;
        public static readonly IbEm.DataEntityProperty&lt;Order, string&gt; CustomerName = new IbEm.DataEntityProperty&lt;Order, string&gt;("CustomerName", false, false, IbEm.ConcurrencyStrategy.None, false, null);
  
        /// &lt;summary&gt;The CustomerAddress &lt;see cref="T:IbEm.DataEntityProperty"/&gt;. &lt;/summary&gt;
        public static readonly IbEm.DataEntityProperty&lt;Order, string&gt; CustomerAddress = new IbEm.DataEntityProperty&lt;Order, string&gt;("CustomerAddress", false, false, IbEm.ConcurrencyStrategy.None, false, null);
  
        /// &lt;summary&gt;The CustomerPhoneNumber &lt;see cref="T:IbEm.DataEntityProperty"/&gt;. &lt;/summary&gt;
        public static readonly IbEm.DataEntityProperty&lt;Order, string&gt; CustomerPhoneNumber = new IbEm.DataEntityProperty&lt;Order, string&gt;("CustomerPhoneNumber", false, false, IbEm.ConcurrencyStrategy.None, false, null);
  
        /// &lt;summary&gt;The CustomerEmail &lt;see cref="T:IbEm.DataEntityProperty"/&gt;. &lt;/summary&gt;
        public static readonly IbEm.DataEntityProperty&lt;Order, string&gt; CustomerEmail = new IbEm.DataEntityProperty&lt;Order, string&gt;("CustomerEmail", false, false, IbEm.ConcurrencyStrategy.None, false, null);
  
        /// &lt;summary&gt;The BicycleModel &lt;see cref="T:IbEm.DataEntityProperty"/&gt;. &lt;/summary&gt;
        public static readonly IbEm.DataEntityProperty&lt;Order, string&gt; BicycleModel = new IbEm.DataEntityProperty&lt;Order, string&gt;("BicycleModel", false, false, IbEm.ConcurrencyStrategy.None, false, null);
  
        /// &lt;summary&gt;The BicycleSize &lt;see cref="T:IbEm.DataEntityProperty"/&gt;. &lt;/summary&gt;
        public static readonly IbEm.DataEntityProperty&lt;Order, string&gt; BicycleSize = new IbEm.DataEntityProperty&lt;Order, string&gt;("BicycleSize", false, false, IbEm.ConcurrencyStrategy.None, false, null);
  
        /// &lt;summary&gt;The BicycleColour &lt;see cref="T:IbEm.DataEntityProperty"/&gt;. &lt;/summary&gt;
        public static readonly IbEm.DataEntityProperty&lt;Order, string&gt; BicycleColour = new IbEm.DataEntityProperty&lt;Order, string&gt;("BicycleColour", false, false, IbEm.ConcurrencyStrategy.None, false, null);
      }
      #endregion EntityProperty definitions
  
      #region EntityPropertyNames
      public new partial class EntityPropertyNames : IbEm.Entity.EntityPropertyNames {
        public const String Id = "Id";
        public const String CustomerName = "CustomerName";
        public const String CustomerAddress = "CustomerAddress";
        public const String CustomerPhoneNumber = "CustomerPhoneNumber";
        public const String CustomerEmail = "CustomerEmail";
        public const String BicycleModel = "BicycleModel";
        public const String BicycleSize = "BicycleSize";
        public const String BicycleColour = "BicycleColour";
      }
      #endregion EntityPropertyNames
    }
    #endregion Order class
  
    #region EntityRelations
  
    /// &lt;summary&gt;
    /// A generated class that returns the relations between entities in this model.
    /// &lt;/summary&gt;
    [IbCore.IdeaBladeGuid("ada4f853-5b03-423a-a51f-0da38018c087", "2.1.4")]
    public partial class EntityRelations : IbEm.IEntityRelations {
  
      /// Explicit static constructor ensures static fields are initialized.
      static EntityRelations() {}
    }
    #endregion EntityRelations
  }
  </code></pre>