What are each of the template types intended usage, pros and cons?
Asked Answered
K

1

5

I have not hardly touched EF4, but I've used Linq to sql quite a lot. I would like to start into one of the EF templates but I have no idea what situations make sense for each or what their intent was.

I have the following possibilities:

  • Data templates
    • ADO.NET Entity Data Model
    • Service-based Database (is this even related to EF?
  • Code templates (I am familiar with T4)
    • ADO.NET EntityObject Generator
    • ADO.NET Self-Tracking Entity Generator
  • Online Templates
    • ADO.NET C# POCO Entity Generator
Kachine answered 20/10, 2010 at 23:29 Comment(1)
You also have the option of "Code First" now just to complicate matters more although it's only a CTP at the moment.Acculturize
C
14

I have no idea what situations make sense for each or what their intent was

Not meaning to sound rude, but did you have a look on MSDN/ASP.NET to find out? There is plenty of information around. And there is a lot to each of those templates, more than i can go into here. There is a MSDN page for each of these.

That being said, i'll give you a quick summary, so people who stumble here have some info.

ADO.NET Entity Data Model

This is the file you create to use Entity Framework as your ORM, and it is mandatory for using EF. You need this before you use any of the others. You can create your EDM with a number of different approaches, including database-first (generate from DB), code-first, model-first, etc.

Service-based Database

I have never heard of this term, and given i've been working with EF a lot lately (and reading), i doubt this will be related to EF.

ADO.NET EntityObject Generator

Generates classes for entities which inherit from the EntityObject class. Identical to the default EF code generator, except instead of putting output code into the Model.edmx.designer.cs (default) file, the code gets put into seperate files. I personally don't see any benefit in this template.

ADO.NET Self-Tracking Entity Generator

Generates classes for entities when you want to develop N-Tier applications (ie if you wanted to allow a WCF/Silverlight app to work with your model). Entities are setup to be 'trackable' by the EF Graph, in order to handle persistence operations from various applications.

ADO.NET C# POCO Entity Generator

My favourite. :) Generates classes for entities which inherit from nothing. They have no idea that they are being used for persistence. Use this for applications when you want persistence-ignorance, testability and loose-coupling of your domain/persistence layers.

Cottonweed answered 21/10, 2010 at 4:19 Comment(1)
I was holding out to see if anyone else would contribute, marking it.Kachine

© 2022 - 2024 — McMap. All rights reserved.