title: Object reference isnt set to an instance of an object
body: <p>I am building a WCF application, with multiple layers, and I am given this exception while trying to add new object to the DB. I will provide you code samples, please try to help me out here. Error is on the line <code>scenaristBLL.Insert(s);</code></p>
  
  <p>Here is my method within which I am trying to create a new Scenarist object in <code>ScenaristController</code> class:</p>
  
  <pre><code>[HttpPost]
          public ActionResult Create(ScenaristViewModel fvm, List&lt;int&gt; scenarijId)
          {
              if (fvm != null)
              {
                  if (String.IsNullOrEmpty(fvm.Scenarist.NameSurname) == true)
                  {
                      TempData["ValidationErrorIme"] = "validation err1";
                      return RedirectToAction("Create");
                  }
                  if (fvm.Scenarist.DateOfBirth == null)
                  {
                      TempData["ValidationErrorGodina"] = "validation err2";
                      return RedirectToAction("Create");
                  }
  
                  Scenarist s = new Scenarist();
                  s.NameSurname = fvm.Scenarist.NameSurname;
                  s.DateOfBirth = fvm.Scenarist.DateOfBirth;
                  s.dateOfDeath = fvm.Scenarist.dateOfDeath;
                  scenaristBLL.Insert(s); // PROBLEM!
                  s = scenaristBLL.Fetch(s.Id);
                  foreach (int scenarij in scenarijId.Where(z =&gt; z != 0))
                  {
                      Scenarij scn = scenarijBLL.Fetch(scenarij);
                      if (scn == null)
                      {
                          return new HttpNotFoundResult("Nepostojeći scenaristId: " + scenarij.ToString());
                      }
                      scenarijBLL.AddToScenarist(scn, s);
                  }
              }
              return RedirectToAction("Index");
          }
  </code></pre>
  
  <p>Also, here is the View class for it:</p>
  
  <pre><code>&lt;table&gt;
              &lt;tr&gt;
                  &lt;td&gt;Name and surname:&lt;/td&gt;
                  &lt;td&gt;@Html.TextBoxFor(modelItem =&gt; Model.Scenarist.NameSurname) @TempData["ValidationError1"]&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;Date of birth:&lt;/td&gt;
                  &lt;td&gt;@Html.TextBoxFor(modelItem =&gt; Model.Scenarist.DateOfBirth) @TempData["ValidationError2"]&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;Datum of Death:&lt;/td&gt;
                  &lt;td&gt;@Html.TextBoxFor(modelItem =&gt; Model.Scenarist.DateOfDeath) @TempData["ValidationError3"]&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
  </code></pre>
  
  <p>I think the DateOfBirth and DateOfDeath might be the problem, since those are in DateTime format, and I am not sure how to get a DateTime format from user input. Just a guess, really not sure.</p>
  
  <p>Furtherly, here are other layers for it...
  BLL:</p>
  
  <pre><code>public void Insert(Scenarist scenarist)
  {
      string error;
      if (scenarist.Validate(out error) == true)
      {
          string[] nameSurname = scenarist.NameSurname.Split(' ');
          string name = nameSurname[0];
          string surname = nameSurname[1];
          dal.Insert(name, null, surname, scenarist.DateOfBirth, scenarist.DateOfDeath);
      }
      else
      {
          throw new ArgumentException("Validation error: " + error);
      }
  }
  </code></pre>
  
  <p>DAL:</p>
  
  <pre><code>public void Insert(string name, string middleName, string surname, 
      DateTime? dateOfB, DateTime? dateOfD)
  {
      using (RPPP111Entities ctx = new RPPP111Entities())
      {
          Scenarist scenarist = new Scenarist();
          scenarist.Person.Name = name;
          scenarist.Person.Middlename = middleName;
          scenarist.Person.surname = surname;
          scenarist.Person.DateOfB = dateOfB;
          scenarist.Person.DateOfD = dateOfD;
          ctx.Scenarist.Add(scenarist);
          ctx.SaveChanges();
      }
  }
  </code></pre>