Entity Framework POCO and Self Tracking entities - c#

Hello
I wonder what's the difference between standard EF objects, POCO and Self Tracking Entities. I was looking the web but couldn't find a valuable introduction.
Any help would be appreciated.

POCO is plain class with only mapped fields. STE is very similar but in advance it contains logic implemented to each property and some collections which are used to tracking changes made to entity.

Related

How to do data mapping with WCF and EF

My Question is about returning EF entity using WCF service. As wcf required Data Members for returning data. Solution i have to do mapping of entity to WCF data members which is quit hectic.
Is there possible solution which reduce my work effort. I tried EntityFramework with WCF - how to return EF entities but available solution have support for vs2010
only.
This is tricky question. You want to pass EF entities through WCF. This is bad in some way, because EF objects are burdened with additional data provided by EF (e.g. for change tracking purposes). The best way to pass objects through domains in your application is create DTO objects. To do that, you can develop additional mappings (with usage of T4 templates) that create this DTOs based on your existing EF entities.

Persisting Data to the Database from a WCF Servicer

I have a WCF application in C# .NET 4.0. I made all my entity classes and can query a sample from the WCF. The sample is just hard coded values.
Now I am ready to persist these in the database. I am lost on how to approach this though. I plan to create tables for each entity class I created, but what is the best way to add the persistent data layer to my existing WCF application. Is Entity Framework a good choice for this? Thanks for any help or suggestions.
What I suggest is to use entity framework code first. It prevents you from re-creating the model/database by hand. Just set it up so that your current entity classes are mapped to the entity framework and it will automatically create the database for you.
If you google entity framework code first, i'm sure u cant miss it.

Updating a Detached Entity Instance using Entity Framework 4.0

I am utilizing Entity Framework 4.0 and WCF. I am new to using Entity Framework and am more familiar with NHibernate. However, I am concerned about detached instances of objects when performing an update.
I have looked on various websites where they retrieve an object, attach the instance to their context, and set all properties to be modified but this leaves two problems:
All fields are updated in the database (not a huge problem, but adds overhead for each update statement).
Many of the examples do not handle situations where you may have an IEnumerable property with objects that also need to be updated (this will be a requirement).
Is there a 'best practice' example of how to handle updating detached entity instances? Any guidance is greatly appreciated.
Brandon, are you able to make use of the self-tracking entities template? This is designed to make handling updates of detached entities much easier. http://msdn.microsoft.com/en-us/library/ee789839.aspx

Best Aproach to Relate A Entity Class to the Correspoding Table in a DataBase

i want to relate each Field of an Entity Class to the corresponding datatable Field.
im working on c# currently
Any Suggestions?
The Entity Framework does exactly that, and very well. It also does a whole lot more such as let you write strong typed LINQ queries directly from your application code.
your other good options are NHibernate or Linq to SQL
this class of frameworks is generally called Object Relational Mapper (ORM)
I would say Entity Framework offers the most conveniences for beginners such as visually configuring your data model. it can infer your object model from your database or it can create a database for you from your object model.
The new Entity Framework Code First approach is incredibly simple and powerful in my opinion
Link
It is what entity framework is doing, isn't it?
Microsoft's ADO.NET team just published an Entity Framework Beginners Guide at their team blog:
Link

Difference between POCO and Self Tracking Entities

I have POCO's in a separate project and now I need Self Tracking Entities. Does anyone know if I need to generate new POCO's that are self tracking and they will replace my current POCO's? Or, do I setup self tracking entities in addition to my current POCO's?
Thanks!
You do not need both. STE is essentially POCO with additional capability for change tracking when disconnected from the ObjectContext. I would suggest that you stick with STE if you have n-tier scenario. For non N-Tier scenario meaning when you are working with your entities on the server side, you can use it like a poco object and let ObjectContext manage change tracking for you.

Categories