title: MVC Model from EDMX file - Add custom annotations to it, and make them stay?
body: <p>How can I add annotations/attributes to my classes or methods of classes in my model, generated from my Model.edmx file? The reason I'm asking this is because every time I add an annotation to a class Model.Designer.cs, this annotation disappears when I make changes to my Model.edmx file through the designer.</p>
  
  <p>More specifically, I am looking for a way to add the AllowHtml annotation to a specific property within one of my model classes, and make it <strong>stay there</strong> even after messing around with it in the model designer view.</p>
  
  <p>Here's the controller code. The <strong>Content</strong> property of the <strong>Segment</strong> class is the one causing my controller to crash when being populated with HTML.</p>
  
  <pre><code>    [FacebookAuthorize(Permissions = AuthenticationController.ExtendedPermissions, LoginUrl = "/Authentication/LogOn?ReturnUrl=~/Segment/Contribute")]
      [HttpPost]
      [ValidateInput(false)]
      public ActionResult Contribute(int id, string content)
      {
  
          var container = new ModelContainer();
  
          var parent = container.SegmentSet.SingleOrDefault(s =&gt; s.Id == id);
  
          var segment = new Segment();
          segment.Content = content; //this crashes with HTML data.
          segment.Owner = AuthenticationController.Authentication.GetUser(container);
          segment.TimeModified = DateTime.UtcNow;
          segment.TimePosted = DateTime.UtcNow;
  
          container.AddToSegmentSet(segment);
  
          if (!parent.Children.Contains(segment))
          {
              parent.Children.Add(segment);
              segment.Parent = parent;
          }
  
          container.SaveChanges();
  
          return RedirectToAction("Index", "Home");
      }
  </code></pre>