title: Validation Error on SaveChanges()
body: <p>I have the following Action method inside my Asp.net mvc web application:-</p>
  
  <pre><code>[HttpPost]
  [ValidateAntiForgeryToken]
  public ActionResult Create(SDJoin sdj, FormCollection formValues)
  {
      Try
      {
          //code goes here
          repository.InsertOrUpdateSD(sdj.StorageDevice, User.Identity.Name, assetid);
          repository.Save();
      }
      catch (Exception ex)
      {
          //code goes here
      }
      PopulateViewBagData();
      return View(sdj);
  }
  </code></pre>
  
  <p>which calls the following method:-</p>
  
  <pre><code>public void InsertOrUpdateSD(TMSStorageDevice sd, string username, long assetid)
  {
      var resource = entities.Resources.AsNoTracking().SingleOrDefault(a =&gt; a.RESOURCEID == assetid);
      if (sd.TMSStorageDeviceID == default(int))
      {
          // New entity
          int technologyypeID = GetTechnologyTypeID("Storage Device");
          Technology technology = new Technology
          {
              IsDeleted = true,
              IsCompleted = false,
              TypeID = technologyypeID,
              Tag = "SD" + GetTagMaximumeNumber2(technologyypeID).ToString(),
              StartDate = DateTime.Now,
              IT360ID = assetid
          };
  
          InsertOrUpdateTechnology(technology);
          Save();
  
          sd.TMSStorageDeviceID = technology.TechnologyID;
          tms.TMSStorageDevices.Add(sd);
      }
  }
  </code></pre>
  
  <p>My model class is as follow:-</p>
  
  <pre><code>public partial class TMSStorageDevice
  {
      public int TMSStorageDeviceID { get; set; }
      public string Name { get; set; }
      public Nullable&lt;decimal&gt; size { get; set; }
      public int RackID { get; set; }
      public string CustomerName { get; set; }
      public string Comment { get; set; }
      public byte[] timestamp { get; set; }
  
      public virtual Technology Technology { get; set; }
      public virtual TMSRack TMSRack { get; set; }
  }
  </code></pre>
  
  <p>but if i call the Create action method i will get the following exception:-</p>
  
  <pre><code>System.Data.Entity.Validation.DbEntityValidationException was caught
    HResult=-2146232032
    Message=Validation failed for one or more entities. See 'EntityValidationErrors' property for more details.
    Source=EntityFramework
    StackTrace:
         at System.Data.Entity.Internal.InternalContext.SaveChanges()
         at System.Data.Entity.Internal.LazyInternalContext.SaveChanges()
         at System.Data.Entity.DbContext.SaveChanges()
         at TMS.Models.Repository.Save() in c:\Users\Administrator\Documents\Visual Studio 2012\Projects\TMS\TMS\Models\Repository.cs:line 1926
         at TMS.Controllers.StorageDeviceController.Create(SDJoin sdj, FormCollection formValues) in c:\Users\Administrator\Documents\Visual Studio 2012\Projects\TMS\TMS\Controllers\StorageDeviceController.cs:line 160
    InnerException:
  </code></pre>
  
  <p>Can anyone advice what is wrong, as i double check my code and every thing should work fine ?
  Thanks</p>