I am using ASP.NET 4.0. I've created a web service that inserts a book. The WebMethod is taking book Entity (the entity generated from EntityFramwork Model) and then insert. my problem is in the application where i referenced this webservice in. in The Reference.cs
class the partial class for the book has only the main feilds of the book ENtity ( no related Entities contained in the book object). my question is how can i include the related entities?
Please if this answer help you remember to click "Mark as Answer".
You are going to have a difficult time getting this to work the way you have it designed. Remember that once the entity gets serialized and sent across the wire, you lose all information that was associated with the
DataContext
Also, unless you specifically included a reference to the assembly with the Entity Framework Models and chose to reuse those types, then the types you are dealing with are only representative clones of the actual Models in your
.edmx
The navigation properties only make sense when the entity is attached to a DataContext, since that is what handles all the magic of calling the database and hydrating the entity being requested. You are essentially getting a POCO from
your web service, but you are trying to use it as though it were still attached to its context.
RAJESH KHUNT
======================================
Microsoft® Community Contributor 2011 | AWARD
MCTS
My Blog Follow Me
TarekHalaseh
Member
485 Points
112 Posts
Web Service and Entity Framework
May 03, 2012 08:53 AM|LINK
Hi,
I am using ASP.NET 4.0. I've created a web service that inserts a book. The WebMethod is taking book Entity (the entity generated from EntityFramwork Model) and then insert. my problem is in the application where i referenced this webservice in. in The Reference.cs class the partial class for the book has only the main feilds of the book ENtity ( no related Entities contained in the book object). my question is how can i include the related entities?
r.rajeshkhun...
Participant
1358 Points
250 Posts
Re: Web Service and Entity Framework
May 03, 2012 09:14 AM|LINK
You are going to have a difficult time getting this to work the way you have it designed. Remember that once the entity gets serialized and sent across the wire, you lose all information that was associated with the
Also, unless you specifically included a reference to the assembly with the Entity Framework Models and chose to reuse those types, then the types you are dealing with are only representative clones of the actual Models in your
The navigation properties only make sense when the entity is attached to a DataContext, since that is what handles all the magic of calling the database and hydrating the entity being requested. You are essentially getting a POCO from your web service, but you are trying to use it as though it were still attached to its context.
======================================
Microsoft® Community Contributor 2011 | AWARD
MCTS
My Blog
Follow Me