Thursday, May 22, 2008

The SP1 Beta does not include updated documentation for Visual Studio 2008, but it is all online.

You can start here: http://vs2008sp1docs.msdn.microsoft.com/en-us/default.aspx

A direct link to EF documentation is: Entity Framework

The tools documentation is not contained within there. Instead it is here: Entity Data Model Tools

The Astoria documentation is here: ADO.NET Data Services Framework

To me the most helpful thing is to see where it lives in the hierarchy so here's a pretty picture

Thursday, May 22, 2008 1:40:36 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 

Check out Ryan Hauert's blog!

Only two EF posts so far, but based on his busy postings in the forums, I imagine there will be more...

Thursday, May 22, 2008 11:02:47 AM (Eastern Standard Time, UTC-05:00)  #     |  Comments [1]  | 

While I was in the middle of a flurry of conference prep and travel in April, I got an email pointing me to an interesting blog post by Dave DeWinter who is using T4 Templates to generate entity friendly CUD stored procedures. Why "entity friendly"? Because of a number of rules enforced by the model such as:

If you are using Stored Procs to do function mapping to an entity, you must use all three operations: Insert, Update and Delete.

if you have an association, the foreign key (aka the ID through the navigation property, e.g. Customer.Address.AddressID) must be used in all three (Insert/Update and Delete) stored procedures

If you do function mapping for a single entity in an inheritance hierarchy, you must have mappings for all of the entities except for abstract base types in the hierarchy.

I have been fighting the concept of modifying the database to enable the model (yeah - call me data-centric yet again and call em "she who worries about annoying the DBA" even though all of the DBAs I've ever met are pretty easy going)) but something has to give somewhere.

Dave and Ryan Hauert (who has been very active in answering forum questions for EF as of late!) are very pleased with the results of their templates.

Interestingly, at DevConnections, Danny Simmons was talking about providing functionality like this in a future version of Entity Framework.

So I'm going to go check this out, and play with it a little bit and see how it goes.

Thursday, May 22, 2008 10:59:54 AM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 

Can somebody tell me why CNN thinks this is a good idea? (Besides the profit motive...)

Thursday, May 22, 2008 9:29:32 AM (Eastern Standard Time, UTC-05:00)  #     |  Comments [1]  | 
 Wednesday, May 21, 2008

I've been spending a lot of time futzing with stored procedures in Entity Framework and losing sight of the fact that one of EF's core features is its ability to do query processing - and that is something it does very very well.

The Stored Proc support is obviously critical for many and while it's there, some scenarios are pretty easy to pull off, while many others are possible  but not so easy to implement and that can get frustrating.

What I'm trying to do is just truly see which things are easily pulled off in the designer (and discovering more than I realized), which are doable and which might take a hack or two to get around.

I think that in my case I was focused on the trees and forgot the the forest.

Thanks to the person who helped remind me of that.

Wednesday, May 21, 2008 6:10:07 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [3]  | 

Scott's a pal, promoting my book and my workshop on twitter!

Wednesday, May 21, 2008 12:15:04 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 

Matthieu Mezil is a Parisian who really digs .NET and the Entity Framework. He writes a lot about it in his native tongue (that would be French ;-)) in his blog.

Since my French, which I studied for 4 years in high school and college (which was a long, long time ago) is pretty rusty, I use google's translation to get a gist of what he is saying in his blog.

But now that Matthieu is an MVP, he has started a mirror blog in English on the msmvps.com/blogs site.

So to recap

Matthieu Mezil in French

Matthieu Mezil in English

Wednesday, May 21, 2008 7:28:01 AM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Tuesday, May 20, 2008

I hadn't noticed this before.

If you have a stored procedure that is mapped to an entity such as "GetCustomersSince" which returns Customer entities, the command is executed when you create the query, not, like with normal queries, when the data is first needed.

In case that sentence was too convoluted...

Here is a LINQ to Entities query (the same is true for LINQ to anything and also for Object Services (context.CreateQuery))

Dim query= From c In context.Customers Select c

For Each cust in Query  <-- command is executed here

'do something

End For

But when calling a function import:

dim custs= From c in context.GetCustomersSince(New Date("2008","01","01")) <--command is executed here

For Each cust in custs

'do something

End For

Looking at the code gen for the function I can see that ObjectContext.ExecuteFunction is called.

Tuesday, May 20, 2008 10:58:19 AM (Eastern Standard Time, UTC-05:00)  #     |  Comments [1]  | 

I'm definitely interested in what people have to say about Danny's post so I have subscribed to the Bloglines citations of it:

http://www.bloglines.com/search?q=bcite:blogs.msdn.com/dsimmons/archive/2008/05/17/why-use-the-entity-framework.aspx

RSS

Don't forget the comment thread in Danny's post as well.

Not surprisingly, the folks who have already made it clear that EF is way too data-centric for them are up in arms and there are some very interesting discussions in their blogs (as well as the comment threads).

I'm not sure if I would compare the investment I am making in understanding how EF works and writing a whole book to share what I've learned to being brainwashed by a "shiny brochure on your desk". Nor do I feel like a "cheerleader" or "parrot". But... whatever... (lame response? Yep! But it's all I have time (or patience) for).

Tuesday, May 20, 2008 8:44:04 AM (Eastern Standard Time, UTC-05:00)  #     |  Comments [2]  | 

Michale de la Maza follows up his popular C# day events with a VB.NET day at the Microsoft office on Tuesday May 27th.

Join us for a relaxed, no cost introduction to VB.NET programming. By engaging in participatory activities, you will learn some of the most common and powerful features of the VB.NET language. This day is not lecture-based. There will be fewer than 60 minutes of lecture material -- almost all of the time will be spent on participant-guided activities. Everyone who attends will learn what interests them at their own pace in a relaxed, tension-free environment with an experienced VB.NET developer and trainer available to answer questions.

RSVPs are required and details are here.

Tuesday, May 20, 2008 7:58:46 AM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Monday, May 19, 2008

The online registration system for Microsoft events is currently broken (or just acting really flakey).

If you are trying to register for Thursday’s free, full-day, Bob & Chris & Jim Roadshow , try the online registration first here:
http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032378634&culture=en-US

If that doesn’t work, you can register by phone

Call the event system directly (877.673.8368) and use the event ID 1032378634.

For more information and details about the event, see Chris’ blog post here:

http://blogs.msdn.com/cbowen/archive/2008/05/02/the-roadshow-rides-again-may-june-edition.aspx

If you are trying to register for a different one of these Roadshow events, just get the EVentID from Chris' blog.

If you are trying to register for other Microsoft events the phone # should be the same, but you'll need to know the EventID of the event you are trying to register for.

Monday, May 19, 2008 9:59:43 AM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 

In the earlier bits, if you changed an association to an inhertiance, the type that becamse the derived type lost its mappings and th emappings for any associations.

Depending on how complex that type is, recreating all of that could be challenging.

I just tried this out in the new bits and the mappings and association mappings all remain intact.

This is great and it will save a tree too, since I can go remove all of that explanation about how to deal with that problem from Chapter 5 of my book!

Monday, May 19, 2008 9:29:10 AM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 

If you have screwed up your Entity Data Model, you may be familiar with safe mode when you try to open the model up in the designer.

But the mapping designer has Safe Mode now, too.

Here is what I get when I am in the middle of creating an inheritance in my model which means that some of my mappings are still a big goofy. I tried to get to the mapping details of the derived type and here is what I see:

The error messages for Entity Framework and the designers are really very helpful.

Monday, May 19, 2008 9:24:40 AM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Sunday, May 18, 2008

Over a year ago I asked a question in the EF forums about being able to use strings in conditional mapping.

It is now possible! Yay.

Sunday, May 18, 2008 10:16:05 AM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 

Having just done a presentation at DevTeach called ".NET 3.5 Data Access Guidance", which I will be doing again at TechEd in a few weeks and I have a CoDe Magazine article on this topic coming up as well, it is definitely interesting to me to see what is probably the first somewhat official looking (it's a blog post, not a white paper) guidance from someone at Microsoft about Why to use Entity Framework.  Outside of a direct comparison of LINQ to Entities vs LINQ to SQL by Elisa Flasko earlier this year , there hasn't been a Microsoft white paper on Entity Framework since June 2006. That's almost 2 years. And that was written when they were first going public with the technology. What Danny is doing here is definitely a first.

In my presentation/article I need to be objective. Granted I am only addressing what's "in the box" - datasets, LINQ to SQL and EF, not nHibernate/ORMs. And I have to be sure not to lean towards EF, which is difficult not to do since I am so focused on it.

But Danny's list is definitely right on. He is highlighting the benefits of EF compared to datasets, compared to LINQ to SQL and also compared directly to nHibernate. It's funny how we (Danny, myself, maybe others) tend to include nHibernate, which has a LOT less users than datasets or LINQ to SQL in these discussions because it is the [relatively] small # of nHibernate users that make the most noise and Danny and I have both been beaten up quite a bit by them, so we now have a natural tendency to be sure to address them at every turn. I think it's become self-defense measure more than anything else. (I shouldn't really speak for Danny here, since he may have different reasons. I know that this is true for me, though.)

One thing that I need to do differently than Danny's post when I do the overall guidance presentation is not just list the places where EF totally outshines the other options, but I also need to address areas where you may prefer the others.

Every time I have done this guidance presentation, I have had someone say to me after the fact, "but I really love typed datasets? Why should I move to EF or LINQ to SQL". My response to them is that if after seeing my presentation, if there is nothing that was truly compelling to them to want to make the change, then typed datasets are probably just the right choice for them.

Sunday, May 18, 2008 9:22:31 AM (Eastern Standard Time, UTC-05:00)  #     |  Comments [2]  | 
 Thursday, May 15, 2008

When VS2008 SP1 beta was released on Monday, I was getting ready to head for Toronto to present three sessions at DevTeach which would be on Wednesday and Thursday. One session was on Astoria another touched LINQ to SQL/EF and DataSets and the last was a deep dive into EF with respect to tiered programming.

The new bits would impact these talks, especially the Astoria and deep dive EF talk a lot and I truly did not want to show people what were now incorrect namespaces, classes whose names had changed, Entity Graphs that did not serialize with services, etc etc.

I made a scary decision and took a huge risk. I updated all of my demos to align with SP1 - this  I did on my dev box at home. This was more than a matter of tweaking some EDMX files and changing class names. The tiered applications needed to be completely reconsidered, rearchitected and rewritten. When I had gotten far enough in this process that I was confident I could finish the transition up, I knew it was time to get the SP1 bits onto my presentaiton laptop.

This didn't go so well. I started the install just before I headed off to my user group meeting. Six hours later I returned to see the install failed because the vista windows sidebar was on. This was 10:30pm. I worked at trying to get the new bits installed until 9am the next morning and then had to give up and head for the airport. To be safe, I threw my CPU, which had what I needed, into my suitcase!

At the speaker dinner that night in Toronto, I was offered a VPC by scott Hanselman who is my savior for the month of May. It already had Vista on it, with VS2008, the Service pack and even Fiddler which I needed for the Atoria session. It was a full day since I began this installation. I hadn't slept and I hadn't been able to complete the demo transitions but I was fully committed.

Or perhaps should be committed.

I pushed my EF debugging skills full bore. But there was more to deal with since the VPC wasn't quite the same as my setup. I had to install all of my databases and change all of the connection strings (there were a lot) inthe many many projects for the 3 sessions in addition to running thorugh every single demo to see where things weren't working.

I didn't get everything fixed on  time and had to go into my presentations knowing that I'd have to skip a few demos and hoped that the bulk of the attendees would feel the same as I did about being able to see how things are not how things were. I think the feelings were mixed (sorry to anyone who found my decision not to be the best).

There is still one entity sql query that is driving me nuts. It keeps saying that "customer" doesn't exist, though the query looks at Customers. Almost as though I had cached something.

I got a few hours of sleep, had chocolate and coffee as my critical helpers, bit the bullet and went for it.

But boy oh boy, I'm not sure if I really need this kind of excitement in my life! :-)

I still need to tighten the rest up so I can get the demos up ontot he DevTeach website, but since not many of the session attendees have SP1 installed yet, hopefully they won't mind waiting a few days.

Thursday, May 15, 2008 6:01:32 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [5]  | 
 Monday, May 12, 2008

The Astoria Team has provided a very impressive list of what's changed and what's new in the new bits for Astoria that were released with VS2008 SP1 today.

I was surprised to see they already have the Batching and Optimistic Concurrency stuff in there that they were only just recently considering.

Here are my own notes from trying to get an Astoria demo working before I had access to the nice list that is now available.

1) If you are using an Entity Framework EDM as your data source , there are some easy to fix (and easy to discover) breaking changes to the model.

See this post on my notes for updating an Entity Framework solution to SP1.

2) The service file is very different. You will be best to create it from scratch then move your logic into the new SVC file.

3) Namespaces and classes have changed.

  • Microsoft.Data.WebClient namespace becomes System.Data.Services
  • WebDataContext becomes DataServiceContext
  • WebDataQuery becomes DataServiceQuery

4) Methods for limiting access and the enums have changed

OLD config.SetResourceContainerAccessRule("*", ResourceContainerRights.AllRead);
NEW config.SetEntitySetAccessRule("*", EntitySetRights.AllRead);

SetServiceOperationAccessRule stays the same

5) WebDataGen is now DataSvcUtil and can be found in C:\Windows\Microsoft.NET\Framework\v3.5\DataSvcUtil. The parameters for this were simplified, too.

I recommend using DataSvcUtil to recreate any classes you want to use in Astoria clients. I actually fixed one up manually before I found DataSvcUtil and it was a pain.

6) The Attribute used to identify the Key field (needed when the field names are not discoverable by Astoria) has changed.

It was <System.Web.DataWebKey()> and was used on the property.

Now it is System.Data.Services.Common.DataServiceKey(propertyname) and is used on the class. It can also take an array of strings if there are multiple keys.

7) The Silverlight and AJAX client libraries are not included with these bits but the AJAX one is  on CodePlex.

That's two of my four demos from my Astoria talk. I'm currently trying to figure out how to retrofit the old ajax data services library into a new application.

http://www.codeplex.com/aspnet/Release/ProjectReleases.aspx?ReleaseId=13357

There are probably lots more goodies in there, but these notes represent the pain I had to go through to get my Astoria demos that I'm doing this week at DevTeach working again.

Monday, May 12, 2008 11:52:25 AM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 

Along with Soma and others, the ADO.NET team has announced that the next beta of Entity Framework is available with the VS2008 Service Pack 1 BETA bits. The Astoria team already has a list of changes on their blog and there will be one coming for EF as well.

In the meantime....

Never a dull moment. I have two EF sessions this week at DevTeach and have to very quikly overhaul my demos.

Here are some of my notes.

EDMX Changes

Designer section

<edmx:ReverseEngineer /> has to be removed. I guess it was hopeful thinking.

SSDL

New attribute required inside of schema (Provider="System.Data.SqlClient")
These attributes had to be removed: DateTimeKind="Unspecified" PreserveSeconds="true"
ProviderManifestToken Attribute in schema declaration needs to be changed from the version number (eg for SS2005 that was ProviderManifestToken=.09.00.3054 now is ProviderManifestToken=2005.

Designer section is now at the bottom of the file. Nice.

You cannot have both the Design view and the XML view of an EDMX open at the same time.

In the Model Browser window, the XML for various pieces of the model are no longer shown in the tool tips. While there are reasons behind this, I REALLY liked this and am sad to see it go. Now I have to always close the designer and open up the XML and trudge through it if I just want to verify something. Oh well.

Designer Changes

Oh my its pretty! It's cleaned up; the Asscoiation names are no longer clogging up the view, it's more flexible wrt to what's available on context menus and it has some nice shortcut icons for zooming etc.

Update from Model

As per a blog post from Noam Ben-Ami a while ago, this has improved enormously. With some minor excpetions (which I have not experienced) the CSDL stays intact when you update even though teh SSDL will be competely rewritten so any changes there will be lost. If you add new fields to a table in the database, and it's obvious in the model where it should go, it will make it into the CSDL.

Code Generated Classes

Best bet: just delete them and let VS2008 regenerate them.

API Changes that I've experienced so far

It is very nice to have full graphs coming in and out of WCF services. :-)

Believe it or not, I haven't run into anything else so far that has impacted my apps except for the fact that I need to completely rearchitect my WCF solutions now that I have graphs to pass back and forth. Will I get this done before my session on using Entity Framework across tiers on Wednesday? Nothing like being forever behind the 8-ball. :-)

The EntityDataSource control

I am not a big fan of drag & drop, but I'm liking this control so far. Here are some of the things that are winning me over.

Easily use inherited types

Easily do eager loading with the IncludePaths property.
Note: There's a bug which is preventing the combination of eager loading when you are using an inherited types. That will go away with the next available build.

Many opportunities to override behavior. There are lots of events and the most important to me (so far) is the one lets me control what context the control will be tied to. By default, every EntityDataSource spins up its own context. That's not good if you want to have relationship management happening.

Dynamically build queries with the properties or just entier an EntitySQL string as the command text.

Note that the where parameter takes an Entity SQL predicate, just like you would use with Query Builder methods.

That's all for now.

Have fun!

Monday, May 12, 2008 11:49:46 AM (Eastern Standard Time, UTC-05:00)  #     |  Comments [3]  | 

 

from Soma:

Visual Studio 2008 and .NET FX 3.5 SP1 Beta available now

Posted Monday, May 12, 2008 9:02 AM by Somasegar

"In the next few hours, the bits for the service pack beta will be available for download here. "

Monday, May 12, 2008 11:37:24 AM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 

Colorado man, author and MS Regional Directory, David Yack, is in Vermont to present at the VTdotNET meeting tonight, thanks to INETA.

He'll be speaking on a topic we have NEVER had in our 6 years at the user group: VSTO. THen off to NJ tomorrow to talk about Silverlight 2.0.

But if that's not diverse enough, he's locked in his hotel room wrapping up a book on CRM. Go David! I've conspired with his wife, Julie, to be sure that he does get downtown to go buy some Lake Champlain Chocolates for his wife. We Julie's know how to stick together!

Special thanks to Infragistics and JetBrains for their monthly raffles and to Goodrich (yes, that Goodrich) Vergennes for sponsoring the cost of the meeting space.

Monday, May 12, 2008 7:36:29 AM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  |