title: Does not contain a definition for 'AddToPosts' and no extension method
body: <p>I am still learning ASP.NET/MVC and following along a tutorial by Matt Blagden (You Tube) on building a Blog..</p>
  
  <p>After making the Post Controller I am getting an error in a snippet of code that handles adding a Tag to a Post if it is a new Post.  My thought is the method AddToPosts should have been generated when I added a new Entity Data Model.</p>
  
  <p>The error is:</p>
  
  <blockquote>
    <p>blog.Models.BlogModel does not contain a definition for 'AddToPosts' and no extension method 'AddToPosts'. PostsController.cs accepting a first argument of type 'blog.Models.BlogModel' could be found (are you missing a using directive or an assembly reference?)</p>
  </blockquote>
  
  <p>The portion of code that is giving me the error is:</p>
  
  <pre><code>            if (!id.HasValue)
          {
              model.AddToPosts(post);
  
          }
  </code></pre>
  
  <p>Here is the entire Post Controller</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.Mvc;
  using blog.Models;
  using System.Data.EntityModel;
  using System.Text;
  
  namespace blog.Controllers
  {
  public class PostsController : Controller
  {
      // Access Model
      private BlogModel model = new BlogModel();
  
      public ActionResult Index()
      {
          return View();
      }
  
      // A way to input sample data into database
      [ValidateInput(false)]
      public ActionResult Update(int? id, string title, string body, etc.....)
      {
          //IF not an admin redirect back to index 
          if (!IsAdmin)
          {
              return RedirectToAction("Index");
          }
  
          // Get Post
          Post post = GetPost(id);
          // Populate simple properties
  
          post.Title = title;
          post.Body = body;
          post.DateTime = dateTime;
          post.Tags.Clear();  // first clear tag list
  
          //ensure input sequence of tag names is not null
          tags = tags ?? string.Empty;
  
          //Split the sequence into a list of tag names
          string[] tagNames = tags.Split(new char[] { ' ' }, etc...
  
          //Get or create each tag that was named
          foreach (string tagName in tagNames)
          {
              //Add the tag
              post.Tags.Add(GetTag(tagName));
  
          }
  
          if (!id.HasValue)
          {
              model.AddToPosts(post);
  
          }
  
          model.SaveChanges();
          return RedirectToAction("Details", new { id = post.ID });
      }
  
  
      // PROMPTS USER TO INPUT DATA FOR DATABASE
      public ActionResult Edit(int? id)
      {
          Post post = GetPost(id);
  
          //ACCUMULATES LIST OF CURRENT TAGNAMES
          StringBuilder tagList = new StringBuilder();
  
          foreach (Tag tag in post.Tags)
          {
              //Append each tagname
              tagList.AppendFormat("{0} ", tag.Name);
          }
          //Gives the tagList to the view
          ViewBag.Tags = tagList.ToString();
  
          return View(post);
  
      }
  
  
      private Tag GetTag(string tagName)
      {   // if tag is set then Get the Tag, if not create a new one (Just like GetPost)
          return model.Tags.Where(x =&gt; x.Name == tagName).FirstOrDefault() ?? etc....
  
      }
  
  
  
      private Post GetPost(int? id)
      {
          // IF id is set then Get the Post, if not make a new one..
          return id.HasValue ? model.Posts.Where(x =&gt; x.ID == id).First() : etc.....
  
  
      // TODO: don't just return true
  
      public bool IsAdmin
      /* READS SESSION STATE */
      {
          get { return true; /*{ return Session["IsAdmin"] != null &amp;&amp; etc...
      }
  }
  </code></pre>
  
  <p>}</p>