Text transcript of show #258 March 23, 2011 Inside Entity ...

leathermumpsimusΛογισμικό & κατασκευή λογ/κού

13 Δεκ 2013 (πριν από 3 χρόνια και 7 μήνες)

111 εμφανίσεις


Page
1
of
8

Inside Entity Framework 4.1 CodeFirst with Jeff Derstadt and Tim Laverty

March 2
3
, 2011

Transcription by PWOP Productions
,
http://www.pwop.com




Text transcript of show #
2
5
8



March 2
3
, 2011



Inside Entity Framework 4.1 CodeFirst with Jeff Derstadt and Tim Laverty



This week Scott sits down with the lead dev and lead PM for Entity Framework to talk about the
improvements from the fir
st version. What
'
s improved and changed? What do they think about NHiberate
or just doing SQL on your own?



(Transcription services provided by
PWOP Productions
)



Our Sponsors






















Hanselminutes is a weekly audio talk show with noted web developer

and technolo
gist Scott Hanselman and hosted by Carl Franklin. Scott

discusses utilities and tools, gives practical how
-
to advice, and

discusses ASP.NET or Windows issues and workarounds.


http://www.telerik.com





http://www.nsoftware.com



http://dotnet.sys
-
con.com



Copyright © PWOP Productions Inc.


Page
2
of
8

Inside Entity Framework 4.1 CodeFirst with Jeff Derstadt and Tim Laverty

March 2
3
, 2011

Transcription by PWOP Productions
,
http://www.pwop.com

Lawrence Ryan:

From
hanselminutes.com
, i t
'
s
Hansel mi nut es, a weekl y di scussi on wi t h web
devel oper and t echnol ogi st, Scot t Hansel man. Thi s i s
Lawr ence Ryan, announci ng show #
2
5
8
, r ecor ded
l i ve
Wednesday
, Mar ch
23
, 2011
. Suppor t f or
Hansel mi nut es i s pr ovi ded by Tel er i k RadCont r ol s,
t he most compr ehensi ve sui t e of component s f or
Wi ndows For ms and ASP.NET web appl i cat i ons,
onl i ne at
www.telerik.com
. In this episode
, Scott
ge
ts
the latest on Entity Framework with Jeff Derstadt and
Tim Laverty.


Scott Hanselman:

Hi, this is Scott Hanselman and
this is another episode of Hanselminutes. Today I
'
m
talking with Jeff Derstadt who
'
s
a
dev lead on Entity
Framework 4.1 and the guy who
makes coffee for
him, Tim Laverty, who
i s
t he l ead PM. How i s goi ng,
guys?


Tim Laverty:

Great.


Jeff Derstadt:

Good. Hi Scott.


Scott Hanselman:

Have you had your coffee
made by your boss today, Jeff?


Jeff Derstadt:

Yeah, he actually made me hot
choco
late this morning
. It was
pretty
cute.


Scott Hanselman:

Oh, that
'
s nice. Okay, so you
guys work on the team that makes the Entity
Framework. Entity Framework is, I think, is it fair to
say it
'
s the way that we, the recommended way to do
data access in
.NET today.


Jeff Derstadt:

Yup, absolutely. That
'
s t he
way we see i t t oo. I f we
'
re doi ng dat a access i n .NET,
you shoul d be usi ng t he Ent i t y Framework.


Scott Hansel man:

Now, a coupl e of year s ago,
let
'
s say maybe like two or three years ago, there are
maybe more options and some of these options still
exist like for example LINQ to SQL is still out there,
it
'
s not being actively worked on but it
'
s shipped, it
'
s
supported, it
'
s there, and then there
'
s ADO.NET kind
of classic record sets and datasets and
data readers
and things like that, and then Entity Framework. How
did it shake out that the Entity Framework is the
recommended way and why were there so many
ways before?


Tim Laverty:

This is Tim. I would say that
for one the first thing I saw with thi
s, Jeff and my
team, we own LINQ to SQL and I think really how it
shakes out is we still see a world where you would
use core ADO.NET. If you
'
re looking at very, very
tight control of SQL statements that
'
s executing into
you database, then we often have t
o push people
down to core ADO.NET. With LINQ to SQL, really it
'
s
a matter of us looking at the EDM vision and looking
at the mapping capabilities
EF
offered and sort of a
balance of which of these are we going to bet on and
add to or add a large feature
set to going forward, and
we felt like the EF had a better path in terms of where
we wanted to go with data access and modeling and
what was the more effective and cheaper solution for
Microsoft.


Scott Hanselman:

And you said EDM vision.
What is EDM?


Ti
m Laverty:

So EDM is the Entity Data
Model and it
'
s basically a way to array a standard that
you can design your entities and relationships
between those entities and offers sort of a good way
of mapping those to relational schemas.


Scott Hanselman:

Okay.
So then everything that
you
'
re doing in the Entity Framework, whether it
'
s
from a model that
'
s done in a visual designer or
whether it
'
s sending code, it
'
s all there
'
s an underlying
EDM, Entity Data Model. Is that right?


Tim Laverty:

Yeah, there is and
what it
allows us to do is I can create or build an EF app and
I
'
ll get an Entity Data Model underneath that.
Because it
'
s Entity Data Model, it makes it really,
really easy for me to use other services. For
example, I can build or very easily build an
OData
service on top of that because the EF model is EDM
-
based and what we picture is going forward
we will
add
other services across Microsoft that are EDM
-
based as well so you can build this EDM model and
get a first class ORM through EF, get a OData ser
vice
very easily and etc.


Jeff Derstadt:

Yes. So this is Jeff. Just to
add on to that, so what this means is anybody who
'
s
using Code
-
First or using the designer to build a data
access stack with the Entity Framework today, you
know, down the road they
'
ll be able to leverage that
existing work that they
'
ve done to build that model
whether they
'
ve built the model using code or with the
drag and drop stuff. In the designer, you
'
ll be able to
do reporting over that, analytics, all kinds of cool
services fo
r free.


Scott Hanselman:

I see. So it
'
s not like
--
it
'
s not
three different things like three totally different code

pa
th
s. I mean, Model
-
First, Database
-
First, and Code
-
First. They all sit on top of the core Entity Framework
thing.


Jeff Derstadt:

Yea
h.


Scott Hanselman:

It
'
s not like three separate
...


Jeff Derstadt:

Yup, that
'
s right. If you look
inside Visual Studio, the designer produces these
XML format and EDMX and you can open that file up
and see all the XML and that kind of represents this
ED
M model. Now that XML then gets interpreted by
the Entity Framework and we use that as kind of our
internal model. Now Code
-
Firs
t
basically generates

Page
3
of
8

Inside Entity Framework 4.1 CodeFirst with Jeff Derstadt and Tim Laverty

March 2
3
, 2011

Transcription by PWOP Productions
,
http://www.pwop.com

the equivalent of that XML but it does it at runtime so
no matter what you
'
re using, the same code path,
the
same kind of model.


Scott Hanselman:

Okay. So the XML is just a
serialized form that represents what you want to do
and in
-
memory it
'
s some kind of an object model that
represents your entity model.


Jeff Derstadt:

Yeah, that
'
s right.


Scott Hanselm
an:

Like XML, I guess what I
'
m
saying is the XML file is an artifact of the larger in
-
memory model. It
'
s not based on XML or anything.


Jeff Derstadt:

Correct.


Tim Laverty:

Yeah, exactly. You can think
of it as it
'
s serializing that EDM model out to XML
.


Scott Hanselman:

Okay. Now a couple of years
ago though when there were these choices, the
original Entity Framework, I think
--
did it come out in
.NET 3.5 or 3.5 SP1?


Jeff Derstadt:

3.5 SP1.


Scott Hanselman:

Some people really embrace
d

it and t
here are some cool books and stuff like by
Julie Lerman. But amongst folks that were already
using features like open source projects rather like
NHibernate, there was a lack of confidence in Entity
Framework and there were some initial features that
the
y didn
'
t feel that it had. What did the public like
and not like about 3.5 and what is different in 4.1?


Jeff Derstadt:

I think what the public liked
about 3.5 was really that you could do some of the
modeling that wasn
'
t possible with some of these
othe
r technologies so you could do different kinds of
inheritance mappings, different kinds of like splitting
tables or joining tables together to represent entities
in a very kind of seamless way. In the original version
Entity Framework, we also made a real
l y bi g
i nvestment i n the desi gner experi ence so that tool s
l i ke NHi bernate, whi ch i s a great tool, has tons of
functi onal i ty but i t di dn
'
t have that ti me, have the
designer
'
s support that was in Visual Studio and so
that was kind of an advantage of using t
he Entity
Framework. LINQ to SQL, on the other hand, had the
advantage of simplicity. It went to one back

end, SQL
Server family of technologies, it had a really simple
programming experience and really just hit that like
I
'
m a developer writing code and
I
'
m trying to get an
ORM
-
based data access stack up and running, and
LINQ to SQL offers the fastest path to do that over the
Entity Framework. It also offered a form of what we
call POCO support so you could write your classes
and they would not have any
dependency on that
data access stack and that was something that the
first version of Entity Framework didn
'
t have and I
think that was one of the most significant feature gaps
between Entity Framework and the other solutions
that really kind of held it ba
ck and so when we release
the second version of the Entity Framework in .NET
4.0 we added the POCO support back. Well, we
added POCO support for the first time, and then
coupled with the designer
'
s support it really made a
really nice solution for people.


Scott Hanselman:

For me, when Entity
Framework 3.5 came out I was kind of a hard core
LINQ to SQL person and I would use LINQ to SQL on
all my demos and I would just
--
LINQ to SQL felt
faster, it felt like the designer was faster and it felt like
it sta
rted out faster in 3.5. In 4.0, it seems like I could
pretty much do everything I do with LINQ to SQL in
4.0 and I can
'
t really tell a difference between the
designer and the startup. It felt like it started up
slowly in 3.5. Is that just in my min
d? Di
d
I get a
faster machine or was there something done between
3.5 and 4.0 to get that kind of out of the box, you
know, it
'
s like file new model, boom, boom, boom, hit
F5 and I
'
m running and it felt more, I don
'
t know, like
crisp I guess.


Jeff Derstadt:

Be
tween 3.5 and 4.0, that was
kind of when we started making that transition to
investing primarily in the Entity Framework. So we
did do work on that experience of I want to get started
using the Entity Framework and I want it to be fast
and as well as fea
ture
-
rich. So it
'
s likely that you
'
re
seeing some of those improvements that we made
there
,
whereas, we didn
'
t make improvements to SQL
metal
and the LINQ to SQL designer. But I think also
like, you know, the other thing that people like about
LINQ to SQ
L was as you said it kind of felt faster and
stuff like that. I think even like the development
workflow, it felt faster with LINQ to SQL because the
concepts that you were using were a lot simpler, there
were a lot fewer of them, you didn
'
t have this ext
ra
layer of mapping and modeling in there, you could
use attributes on your classes and things like that. So
there definitely was a simpler feel to LINQ to SQL
even though it kind of seem like it could do similar
things in a lot of cases.


Scott Hanselman
:

Right.


Jeff Derstadt:

But the truth of the matter is
that the Entity Framework definitely offers more in
terms of object relational mapping technology and the
different layers that are in the Entity Framework is a
much more robust, richer experience or
piece of
technology and so that
'
s where when we started
working on EF 4.1 we said, well, one of the things
people like about these other technologies is they
'
re
simple and few concepts so let
'
s start to get that kind
of experience when we start thinking ab
out the next
versions of the Entity Framework.


Tim Laverty:

The only thing I was going to
say perf
-
wise is that we do
--
with every release we
set aside or we block off specific time to look at perf in

Page
4
of
8

Inside Entity Framework 4.1 CodeFirst with Jeff Derstadt and Tim Laverty

March 2
3
, 2011

Transcription by PWOP Productions
,
http://www.pwop.com

terms of our startup, also in terms of the SQL that w
e
generate that we execute into database both and we
definitely did that with EF 4.0 and plan to do it going
forward.


Scott Hanselman:

One of the things that I found is
that because it
'
s so simple, I end up using Entity
Framework like I did with LINQ to S
QL in a one
-
to
-
one relationship. So when I do a Database
-
First
where I design my database and then I drag my
tables in and automatically get my model or if I do a
Code
-
First, I
'
m finding that my model to database kind
of mapping is one
-
to
-
one and I
'
m feel
ing a little bit
guilty about that and I
'
m wondering if I
'
m really only
scratching the surface of what
'
s possible and usually
it
'
s because of confusi on maybe perhaps on my part
about let
'
s say I have l i ke a customer model but the
customer model actually ha
s two or three tables,
customer, customer i nfo, customer address, I
'
m not
real l y cl ear how that mappi ng works from an i nsert
perspective like I can visualize from
a
reading
perspective that I
'
ve got this customer object and I
'
m
going to go and get one and
the Entity Framework will
go and map how these three tables are in fact one
object and that
'
s nice. But on the insert, how does it
know and how do I write code to have one customer
object fan out to multiple tables? I think that
'
s
a

question a lot of peo
ple have.


Tim Laverty:

So it probably depends on this
is really about initial model creation. If I want to have
one entity or one class that
'
s mapping to multiple
tables, then when you create your model you specify
the EF, what properties map to what spe
cific columns
and what specific tables. In terms of generation of
CRUD statements or a generation of read statements,
you
'
re basically using the same logic like EF is looking
at the entity, it
'
s looking at its mapping layer and
saying okay, how do the pro
perties in this entity
mapped to each tables and which columns on those
tables? It
'
s generating the CRUD statements based
off of that and it has the intelligence to walk through
what the dependencies are and so on so that it
executes the statements in ter
ms of order. So I guess
what I
'
m after is like the bonus with EF is that you can
actually create that kind of mapping if you want to
take those three tables and map them into a single
entity where with some of the other technologies you
can.


Scott Hansel
man:

I
'
ve heard a lot as I presented
EF, Entity Framework
-
related talks at small user
groups and stuff that some of the database folks out
there are uncomfortable. These database guys that
kind of grew up in that space, when I was
programming in the early
and mid
-
'
90s and doing stuff
on like SQL 4.2.1, it was a very clear delineation
between the three tiers and the three job titles. There
was like an old database guy with a beard or lady with
a beard, there was the UI guy who was the button
-
dragger, that
was me
,
and then there was the
"
I don
'
t
know how to do the UI
"
guy and he wrote the services
in the middle of the COM objects in the middle. The
database guy, his job security was based on, you
know, he knew everything that runs over the
database. He add
ed special index columns and he
wrote custom
'
s procs and everything like that, and
then I hear now that maybe that guy is not needed.
Where do you think those roles evolved to? Should
the database guys start learning EF and move up or
should the coder mo
ve down into the database?


Tim Laverty:

This is funny. So I have EF for
DBAs talk in Orlando next week that I
'
m doing so I
'
ve
been thinking a lot about this and I come from, well, I
didn
'
t have a beard but I was a database guy before
coming to Microsoft.
So we actually don
'
t see the
database guy becoming irrelevant if you will. EF
works great in a DBA
-
centric work flow as well like it
works well with stored procedure, it works well with
views. If you
'
re in a shop where you
'
re stored
procedure
-
oriented
and you want that abstraction
layer or you want to have a buffer from the developer
in terms of to handle security or you want to
specifically tune queries, then we definitely
recommend that you continue to use stored procs,
you write your stored procs in
those specific cases or
you write your views and they
'
ll map through EF just
fine. So I guess we think of it as EF work
s
well for
your shop and it
'
s sort of independent of what your
shop workflow is like it will basically be able to click in
and offer you
benefit whether you have very
segmented roles with the database guy with the
beard, your middle tier and your front
-
end guy, or
whether you
'
re a guy that wraps all of that up.


Scott Hanselman:

Hi, this is Scott coming to you
from another place and time.
Are you using Agile
Practices to manage your software development?
There are lots of tools in the market that manage the
steps of a project, but most of them focus on
individual roles. Get ready for a solution that caters to
the success of the whole tea
m. The guys at Telerik
introduced TeamPulse to the Agile Project
Management Tool that will help you gather ideas,
estimate, plan, and track progress in a common
workspace. Finally, companies, regardless of their
size, can use a lightweight and convenient
tool that
makes all the stakeholders work as a united team
even if they
'
re in different countries. By combining
intuitive interface and the power of Silverlight,
TeamPulse removes the road blocks that you typically
face in applying Agile in an effective
manner. No
more lost data, no disparate systems, no lack of
critical analytics regarding the health and velocity of
your project. See for yourself, get a free copy for five
users in one project at
telerik.c
om/teampulse
,
and
please do thank Telerik for supporting Hanselminutes
on their Facebook fan page,
facebook.com/telerik
.
We do appreciate it. There wouldn
'
t be a
Hanselminutes if there wasn
'
t Telerik helpi
ng us.


I guess that with the database guy with the beard or
gal, in an enterprise it seems like the bigger the

Page
5
of
8

Inside Entity Framework 4.1 CodeFirst with Jeff Derstadt and Tim Laverty

March 2
3
, 2011

Transcription by PWOP Productions
,
http://www.pwop.com

company the more likely there is a dedicated person
that does that and I
'
ve heard from the community,
from the public kind of these two conflic
ting
statements. One is that Entity Framework is only for
big enterprises and that
'
s one statement, and then the
conflicting one is no, no, we
'
re way too big for Entity
Framework. You know, our database is so big or it
'
s
so important, or our company is s
o big that we can
'
t
use it because we have a zillion tables and all custom
procs. How do I reconcile those?


Jeff Derstadt:

I think the way that you
reconcile them is they
'
re both not true. So Entity
Framework can be used for, you know, if you
'
re not
an
enterprise, you
'
re just getting started with the
greenfield application, you want to build the model
using code or with the designer, have us generate a
database for you just so you can start writing your
actual application and know that Entity Framework i
s
going to help facilitate getting all your data stored in
the database for you. So we work, kind of un
-
madden
the things and on the enterprise side we do scale up
to fairly large models and we have the flexibility to do
complex mappings that you often se
e and shops that
have pretty large complicated database schemas and
that
'
s where kind of some of that extra power and
flexibility of the Entity Framework
'
s mapping comes
into play. I think we definitely have like, you know,
release after release we
'
re get
ting better on our SQL
generation and from what I
'
ve seen about DBAs being
like the gatekeeper of no SQL shall enter my
database without my expressed written TBA report
kind of thing, I think in those cases I
'
ve seen the
developers view like I
'
ve used Enti
ty Framework, here
are some of the SQL that generates the show to the
DBA
,
and the DBA is like, hey, this isn
'
t bad, this is
pretty good SQL. In fact, it
'
s probably just as good as
a person could write in a reasonable amount of time.
Entity Framework eve
n offers the ability, you know, if
you don
'
t like the SQL that
'
s generated for a LINQ
statement you can always kind of have the option of
dropping down and having Entity Framework execute
your own SQL for you. So in that regard, Entity
Framework is pretty
well used in enterprise scenarios
and by enterprise customers.


Scott Hanselman:

One of the things that I
'
ve
heard as a negative about Entity Framework is that
it
'
s unclear how to do things like caching and second
level caching. I
'
ve heard that as it rel
ates to
NHIbernate which has kind of caching baked in.
What do you think about that?


Tim Laverty:

It
'
s good criticism. I mean, we
still have a number of features that are on our back
log that aren
'
t into product yet. We don
'
t have a first
class, second
level cache, or a caching provider
model. We look at NHIbernate set of environment, it
'
s
something that we want to build and plan to have in a
future release for sure.


Scott Hanselman:

Tim, when people say why
doesn
'
t Microsoft just use this existing ope
n source
project and that won
'
t mean not just from the context
of Entity Framework but kind of anything that we do,
why do we as a company build something versus pick
something in the community? I know that sometimes
we do in the case of like jQuery and j
Query
-
y on the
web side, but how are those decisions made like let
'
s
build versus buy or build versus support in the
community?


Tim Laverty:

I think that it varies from
technology to technology, that it depends on licensing
and how much IP we have in the
space already and
how much we want to innovate there, like do we think
that we could build something that
'
s significantly
better than what
'
s there and so on.


Scott Hanselman:

Entity Framework is going to
be supported forever in the sense of this is the wa
y
we
'
re doing things going forward. So you
'
re planning
on moving forward. EF 4.1 just came out and there
'
ll
be like a 5.0 and a 6.0 so we
'
re not going to switch
database models again?


Tim Laverty:

We have absolutely no plans to
switch database models or
switch data access APIs
again. We have a funny acronym called YADA, Yet
Another Data Access layer. We don
'
t plan on having
a fully different data access layer. EF should be it. I
mean, with EF it
'
s strategic for Microsoft. It
'
s based off
on the EDM mo
del. We
'
re building a number of
services on top of it. EF is your ORM, you have data
services or OData built on top of it. We plan on
shipping others as well.


Scott Hanselman:

And you guys, you
'
re
supportive of people using whatever they like. I mean
Entity Framework uses ADO.NET underneath,
NHibernate will end up using, you know, going direct
to SQL depending on what provider they
'
re using
underneath. Do you care? I mean, ultimately we
'
re
trying to sell Windows. Does it matter to you whether
someon
e uses EF versus NHibernate versus
whatever? LOBL gen?


Tim Laverty:

I mean, not particularly like it
'
s
the .NET ecosystem and that
'
s what we
'
re about. I
mean, we have EF because we think that it
'
s a great
ORM and it feeds this ED ecosystem nicely and
ma
kes it really easy for you to build OData services
and other service on top of it. It
'
s got grey VS
integration and so on. We
'
ve got a lot of chips on it,
we
'
re betting a lot on it. But yeah, I mean in reality it
'
s
l i ke we
'
re here to enhance and bui l d o
n the EDM
ecosystem, or sorry, on the .NET ecosystem and
these other technol ogi es are great as wel l.


Scott Hanselman:

So i n 4.1, i s i t correct to say
that EF 4.0 shi pped wi th .NET 4.0 but EF 4.1 i s i ts
own thi ng? It
'
s an add
-
on. Is i t a repl acement or
d
oes it sit on top of the stuff that shipped in 4.0?


Page
6
of
8

Inside Entity Framework 4.1 CodeFirst with Jeff Derstadt and Tim Laverty

March 2
3
, 2011

Transcription by PWOP Productions
,
http://www.pwop.com


Tim Laverty:

It is an add
-
on on top. So EF
4.1 is our first out
-
of
-
box release. It
'
s the first time we
shipped outside of the .NET framework which we
'
re
super excited about because our thinking is this
kind
of allows it to iterate quicker. So we
'
ve got a huge
back log, you preference second level of cache,
there
'
s one earlier and what we feel like what this is
going to let us do is it
'
s going to let us iterate and ship
out of box on a more consistent a
nd rapid cadence.
EF 4.1 doesn
'
t replace EF 4.0. It
'
s a layer on top of it.
It adds Code
-
First and the DB context to API surface.


Scott Hanselman:

Were you guys influenced by
the ASP.NET team and MVC shipping out of band or
was that like
--
I kind of f
elt like at Microsoft the
culture wasn
'
t really supportive of doing things as we
say out of band meaning doing things now and
shipping things now as opposed to waiting for the
next version of Visual Studio and I feel like the guys
on the MVC team really st
arted innovating in the
sense of we can do something, we don
'
t have to wait
for you, Visual Studio. Or is that something that
'
s kind
of invented on both sides?


Jeff Derstadt:

No, I think that they were
definitely a model for us and exactly around like we

want to be able to ship more frequently, get the
features to the customers more, you know, as quickly
as we can were all goals of ours and we saw what
they were doing and said, hey, we should do that too.
You know, to give the MVC and ASP.NET team credit

and you, Scott, we got a lot of feedback from them not
just about how to ship the bits but about the content of
the bits and the functionality. So we actually think of
our relationship with MVC and ASP.NET as a pretty
successful one in terms of getting o
ut a pretty good
product that people seem to be pretty happy with.


Tim Laverty:

Yeah. I mean, I
'
d just add to
that. We
'
ve got a good tight partnership with the
ASP.NET guys like they look at our code, they critique
us, they brought a lot of new ideas to
us saying, hey,
we think you guys should do this or like they
'
ve looked
at our stuff and given us some affirmative feedback
and criticism about making it simpler, making it easier.
Certainly from a ship perspective we
'
ve learned a lot
from them and they
'
r
e a good model for us. Yeah,
we
'
re doing this thing a little bit different than they are
naturally, but they
'
ve been a good model for us to
learn from shipping stuff out of band and on a quicker
cadence. So yeah.


Scott Hanselman:

Yeah. That
'
s right.


J
eff Derstadt:

Yeah, yeah. I actually,
whenever we ship a new like CTP especially the
Code
-
First stuff, I always look forward to the next
couple of days getting a mail from you, Scott, or David
Ebo, or Phil Haack about, you know, why the heck did
you do i
t this way? This is ridiculous, like you
'
ve got
to change this. So that always kind of gives me a little
smile when I get feedbacks from you guys and I call it
the mocking feedback because you like to make fun
of the silly choices we
'
re making in our CTP
s.


Scott Hanselman:

It
'
s so funny that Microsoft
people, I don
'
t know it it
'
s like Microsoft culture thing
or if we
'
re like trained or maybe it
'
s the Kool
-
Aid to
take our criticism like please, sir, can I have another.
You know, it
'
s like, you suck, what
did you name it?
DB, database, what kind of freakish class name is
that? You guys are smoking over there. Oh, thanks,
I
'
ll take that and ask the team. I
'
m super excited about
your feedback.


Tim Laverty:

Exactly.


Scott Hanselman:

Take your licks and k
eep
going.


Jeff Derstadt:

Right.


Scott Hanselman:

When I think it was CTP 4.0,
CTP 5.0 came out, it was like, I mean it wasn
'
t literally
but it was like Microsoft Database Access Entity
Framework Community Technology Preview 4.0 or
whatever and it was su
ch a ridiculously long name
and I saw it on my blog, I think it was like 3:00 in the
morning and I was in a weird mood or whatever and I
was like I reject this name, I reject it and I now declare
that the Entity Framework is the magic unicorn
edition. Whe
n you guys woke up the next morning,
were you like real mad because I was just being silly.
I didn
'
t know it became like a thing.


Jeff Derstadt:

I think we thought it was
hilarious and it
'
s to the point where we feel the guy
'
s
office is full of inflatable
unicorns when he went on
vacation once and we
'
ve got a little unicorn crossing
signs in our hallways now and when the EF 4.1 t
-
shirt
comes out it
'
s called the magic unicorn edition.


Scott Hanselman:

That
'
s awesome, that
'
s
awesome. I was making sure tha
t I was still cool with
you guys.


Jeff Derstadt:

It
'
s pretty good. People are
really like that and it
'
s actually a rallying point anyway.


Scott Hanselman:

Oh, that
'
s cool. That
'
s cool.
Back to the thing about shipping out of band, it seems
like there
'
s
more and more stuff coming out. Thinking
of you guys, Entity Framework, and MVC, and also
SQL Compaq where we
'
re not necessarily having to
install stuff like you could but with NuGet and the
package management I can go and get SQL Compaq
edition, EF 4.1,
MVC scaffolding and things like that
and I
'
m bringing them down at a project level where I
use the term Lego pieces, I
'
ve been talking about this
for a couple of months now, the idea that suddenly
the Legos are the right size, like a Lego that I have to
r
un on MSI on is not a good Lego. Do you know what
I mean?


Page
7
of
8

Inside Entity Framework 4.1 CodeFirst with Jeff Derstadt and Tim Laverty

March 2
3
, 2011

Transcription by PWOP Productions
,
http://www.pwop.com


Jeff Derstadt:

Yeah. Yeah, we love NuGet.


Scott Hanselman:

Was it a design, a conscious
decision to make things so pluggable like that?


Tim Laverty:

Certainly. Like when we saw
NuGet, it made
us really excited just because we
build this piece, the EF 4.1 that sat very nicely on top
of EF 4.0, and we saw NuGet as a really great way of
delivering it. Not only is it like walking through a
project that
'
s really, really simple, just drop your Lego
piece if you will into that project. So yeah, when we
saw it we were super excited just because we thought
it fits so well with what we
'
re doing.


Scott Hanselman:

The fact that MVC and you
guys both use T4 templates for Code Generation
stuff, and I guess
is it true that you guys support
plugging in your own T4 templates to generate
classes pretty much any way you want?


Jeff Derstadt:

Yeah, that
'
s correct.


Tim Laverty:

Yeah. Or you can add in ours.


Scott Hanselman:

Is that a coincidence or how
did you
guys get into the whole T4 thing?


Tim Laverty:

This was one of the big
criticisms of what we did in our initial release in 3.5
SP1, it was that the code that we generated not only
could
--
you couldn
'
t write POCO classes, but you
couldn
'
t really change wh
at we were generating for
you from a Code Gen perspective. So this is one of
our big adds in EF 4.0 actually. It was, hey, you can
write your POCO classes and you can also just
completely takeover and do whatever Code Gen you
want. We shipped a few Code
Generation strategies
in the box and then we also use Extension Manager
to ship a few others like I think our POCO template is
on Extension Manager as well. We
'
re pretty
consi stentl y seei ng peopl e take our templ ates and
tweak them for thei r domai n for wh
atever mini
convention they have or in some cases I
'
ve seen
chaps where they
'
ve got a business object layer
already. So they have specific based classes in the
interfaces they
'
re using and they
'
ll change our T4
templates text to use their stuff. So they
'
ll take our
general term and we think it
'
s great. So just T4 in
general, we
'
re super excited about it. We think it
'
s
great and we see people consistently using it to
author our Code Gen and takeover, which is
awesome.


Scott Hanselman:

Yeah. I
'
m trying
to get the T4
guys to realize that this is a big deal and that T4
needs to have syntax highlighting and I think some
people are a little bit afraid to let the farm on on T4
because it seems like a small thing but when you
open the file up the Visual Studio
it gives you a sense
of like should I be here?


Jeff Derstadt:

That
'
s a grey world.


Scott Hanselman:

Yeah. It
'
s just a little bit scary.
I mean, maybe that just kind of underlies the whole
kind of joke about how, you know, why .NET
programmers are use
less unless they
'
ve got a drag
and drop support inside of Visual Studio. But every
time I open a T4 template and I don
'
t get like
someone doesn
'
t hold my hand, I
'
m a little bit like, oh,
yikes, am I supposed to
...
You know, I
'
ve open the
door and I shou
ldn
'
t have done that.


Jeff Derstadt:

There
'
s actually a pretty nice
little Visual Studio add
-
in from a company called
Tangible, the Tangible T4 Editor which gives you the
syntax highlighting and you can tell like what code is
going to be output versus wha
t code is running to help
run the template? That helps a lot. It avoids the
battle of Advil syndrome that you get from working on
templates.


Scott Hanselman:

Yeah, yeah. We should buy
them or something, I don
'
t know. I guess this should
be a good exam
ple of the kind of think where we
could solve a problem by going out there in the
community and bringing something in. But yeah, we
should all keep putting pressure on them because it
'
s
all because we love T4 and not because we
'
re picking
on the team.


Ti
m Laverty:

Yeah, definitely.


Jeff Derstadt:

Yeah.


Scott Hanselman:

So how do we get EF? We
can go into NuGet and it
'
s called Entity Framework,
it
'
s the package. You guys changed the name a little
bi t that
'
s why I j ust say i nst al l package Ent i t y
Framewo
rk. Is there also MSI or something I should
install on my system?


Tim Laverty:

Yeah. Well, you don
'
t have to
like you can use NuGet and you
'
ll get what you need
like it builds on top of EF4.0 so you can have
Net
Effects
installed, then you can use NuGet
and you
'
ve
got what you need and you just go to town. You can
go get our MSI if you want
to GAC it
and that
'
s off at
the MSDN download center. That will also give you
our DB context generation for Model
-
First and
Database
-
First workflows.


Scott Hanselm
an:

Cool. So I don
'
t have to put
anything in the
GAC
or run MSI if I don
'
t want to. But
if I do, then I can go and get the installer.


Tim Laverty:

That
'
s right.


Scott Hanselman:

All right, very cool. And we just
published, or actually I think we
'
re i n
the process of
publ i shi ng an Enti ty Framework Code
-
Fi rst tutori al on
the ASP.NET websi te and I
'
l l add a l i nk to that on the

Page
8
of
8

Inside Entity Framework 4.1 CodeFirst with Jeff Derstadt and Tim Laverty

March 2
3
, 2011

Transcription by PWOP Productions
,
http://www.pwop.com

show, and there are lots of different Code
-
First
tutorials that are out there so people can try each of
the different modeling styl
es of Database
-
First,
Model
-
First, or Code
-
First and I guess we
'
re going to
be doing some demos of this at MIX too so people will
really get as much of this as they can handle.


Scott Hanselman:

Awesome.


Jeff Derstadt:

Yeah, awesome.


Scott Hanselman:

Tha
nks guys. I really
appreciate your time. This has been another episode
of Hanselminutes. We
'
ll see you again next week.