Tuesday, 12 August 2014

Error : The object cannot be deleted because it was not found in the ObjectStateManager.

8/12/2014 - By Pranav Singh 1

This article will show you how you can remove the remove the mention error “The object cannot be deleted because it was not found in the ObjectStateManager.” While performing the delete operation from .sdf database using linq query in entity framework.




So here is the solution for the error “The object cannot be deleted because it was not found in the ObjectStateManager.”

StudentManagerEntitie objentity = new StudentManagerEntitie();
            StudentDetail objstudentdetail = new StudentDetail();
            objstudentdetail.Id = Id;
            objentity.StudentDetails.Attach(objstudentdetail);
            objentity.DeleteObject(objstudentdetail);
            /*Save data to database*/
            objentity.SaveChanges();

In above code please check the bold part of the code this code will help you to remove the error.

About the Author

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Get Updates

Subscribe to our e-mail newsletter to receive updates.

Share This Post

1 comment:

Please let me know your view

Free Ebooks


About Us

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Contact Us

For writing article in this website please send request by your

GMAIL ID: dotnetpools@gmail.com

Bugs and Suggestions

As we all know that this website is for sharing knowledge and providing proper solution. So while reading the article is you find any bug or if you have any suggestion please mail us at contact@aspdotnet-pools.com.

Partners


Global Classified : Connectseekers.com
© 2014 aspdotnet-pools.com Designed by Bloggertheme9.
back to top