title: Exception: "Can't perform Create, Update, or Delete operations on 'Table(Property_main_image)' because it has no primary key."
body: <p>I am inserting an image in the folder and its url in database but it throws some kind of exception. I am using linq to sql.</p>
  
  <p>it inserted the picture successfully in the folder but does not inserts the path in the database and throws the exception.</p>
  
  <pre><code>protected void Button1_Click1(object sender, EventArgs e)
      {
         using (Property_dbDataContext context = new Property_dbDataContext())
           {
              string imagename = _PictureUpload1.FileName.ToString();
              Property_main_image main = new Property_main_image();
              main.prop_id = "5";
              string imagepath_2 = "wp-content/uploads/Main_Images/" + imagename;
              main.image_url = imagepath_2.ToString();
              _PictureUpload1.SaveAs(Server.MapPath(imagepath_2));
              context.Property_main_images.InsertOnSubmit(main);
              context.SubmitChanges();
           }
      }
  </code></pre>
  
  <p>Exception:</p>
  
  <blockquote>
    <p><strong><em>Can't perform Create, Update, or Delete operations on 'Table(Property_main_image)' because it has no primary key.</em></strong></p>
    
    <p><strong>Description:</strong> An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more
    information about the error and where it originated in the code.</p>
    
    <p><strong>Exception Details:</strong> System.InvalidOperationException: Can't perform Create, Update, or Delete operations on 'Table(Property_main_image)'
    because it has no primary key.</p>
  </blockquote>