Sunday, December 07, 2008

LINQ and Entity Framework Posts for 12/1/2008+

Note: This post is updated daily or more frequently, depending on the availability of new articles.

Updated 12/7/2008 2:00 PM PST
• Updated 12/5/2008 5:30 PM PST
• Updated 12/4/2008 5:30 PM PST

Entity Framework and Entity Data Model (EF/EDM)

••• Colin Meek, who hasn’t added a item since 5/13/2008, went wild and posted the following three articles on 12/7/2008:

••• Simon Segal asks on 11/6/2008, Will Microsoft ORM products ever support the ubiquitous MS Access? My take: It’s about as likely as ADO.NET Data Services with an Access data source (i.e., highly unlikely.)

The EF Team’s detailed “Table Splitting”: Mapping multiple entity types to the same table post of 12/5/2008 explains how to minimize retrieving large blob columns or columns that contain sensitive data. The author says:

There are several ways with which to accomplish this in the Entity Framework, but one of the more flexible and powerful approaches is not much discussed. In this blog post, I will provide a soup-to-nuts example, from DDL to client code, of how to implement this pattern.

Julie Lerman announces that her DevTeach session materials are available in her DevTeach: EF Mapping Session Materials are on DevTeach site post of 12/2/2008.

Kristofer Andersson’s Tools - Part 8 - Add-ins - “Model First” in Entity Framework post of 12/4/2008 describes the initial version of the Huagati DBML/EDMX Tools’ new model-first design feature for Entity Framework v1. Model-first depends on the EDMX cleanup procedure described in Kris’s Tools - Part 7 - Add-ins - How to deal with the Entity Framework designer and orphaned entities post of 11/27/2008. Kris says:

This first version supports generating new databases from scratch, essentially doing what Microsoft have described in their “Model First” article in the EFDesign blog. (And what was demonstrated during their “Entity Framework futures” session at PDC2008). The next version will support incremental SQL-DDL generation identical to the L2S version described in Tools Part 6; generating scripts including only the differences between the model and the underlying database.

You can download the Huagati DBML/EDMX Tools version 1.51 (beta) here. Kris’s post includes an illustrated step-by-step example.

Anthony Sneed’s “Flexible Data Access With LINQ To SQL And The Entity Framework” article for MSDN Magazine’s December 2008 issue describes a data access layer (DAL) that uses Data Transfer Objects (DTOs) to carry data across service boundaries in a persistence-ignorant manner, as shown in this diagram:

Tony incorporates change state into the data contract between client and service, which lets you attach entities that have been disconnected from their original context. His article includes a link to sample code from the MSDN Code Gallery that uses Northwind’s Customers and Orders tables as the data source.

Anne Epstein describes her experience attempting to get EF v1 to work with a legacy database in her NHibernate and Entity Framework Battle it Out in the Real World post of 12/3/2008. She and her team finally abandoned EF v1 in favor of NHibernate.

Stefan Cruysbergh’s ADO.NET Entity Framework : Querying metadata post of 12/2/2008 provides 20 sample LINQ queries against EF metadata. The links to the topics didn’t work for me, but you can go directly to the Web site article, which describes a needed addition for EDM developers.

The ADO.NET Team posted a Migrating from LINQ to SQL to the Entity Framework: Stored Procedures for data retrieval article on 12/2/2008, which describes how LINQ to SQL features that support stored procs might be implemented in EF v2. For example, it appears the EF v2 won’t support hand-written code for stored procedures that return multiple resultsets. Code generation to handle stored procs that return scalar values “is being strongly considered for the next release of Entity Framework.” The team appears to becoming non-committal about the details of EF v2’s feature set.

Alex JamesPluralization post of 12/1/2008 explains how pluralization/singularization will work for English class and member names in Entity Framework v2.

It seems to me that the EF team should adopt at least the naming customization features of the Huagati DBML/EDMX Tools. After all, the features currently proposed for EF v2 are simply clones of LINQ to SQL’s implementation.


Mark Monster continues his LINQ to SQL Doing It Manually series with the Part 3 – Relationships episode of 12/6/2004.

•• Jeffrey Schwartz’s “Is LINQ to SQL Dead” post of 12/4/2008 for Redmond Developer News’ DataDriver blog carries this deck:

As Microsoft aligns behind ADO.NET Entity Framework, some V2 features may slip. Could that breath new life into LINQ to SQL?

Jeff quotes Stephen Forte as saying, "It is dead as a door knob. In my opinion there is going to be a shakeout; the first casualty will be LINQ to SQL," Forte told the New York City .NET User Group. Forte’s opinion might be clouded by his membership on the Entity Framework’s Advisory Panel, whose conclusions from their first meeting have never been made public, despite the ADO.NET Team’s promise to do so.

Here’s Andrew Brust’s opinion:

To me it's like Blu Ray [EF] winning out over HD DVD [LINQ to SQL]. While people who bought HD DVD players and discs are not happy about the outcome, they represent a small group of early adopters, all of whom were warned of and understood the risks in making an early commitment. [Product analogies added.}

LINQ to SQL is a component of ADO.NET 3.5 pre-SP1. EF released with SP1. No one from the ADO.NET Team warned LINQ to SQL users that adopting LINQ to SQL, the first release of a Microsoft-supported data access product O/RM tool, that it was to be abandoned as soon as the ADO.NET Team released an unfinished version of EF. It’s also worth noting that sales of BluRay DVD players never have gotten off the ground.

Jeff quotes me as the contrarian at the end of his story.

Scott Hanselman interviews Rob Conery in the podcast from the Hanselminutes Podcast 140 - Rob Conery learns about Domain Driven Design post of 12/4/2008.

Matthew Hunter announces his LINQ to SQL Entity Base Version 1.0 Final version is available for download from CodePlex.

Anthony Sneed’s “Flexible Data Access With LINQ To SQL And The Entity Framework” article for MSDN Magazine’s December 2008 issue describes a data access layer (DAL) that uses Data Transfer Objects (DTOs) to carry data across service boundaries in a persistence-ignorant manner. See the EF/EDM topic for more details.

Eric White describes code to join SQL Server 2000+ tables to Excel 2007 worksheets in his Joining LINQ to SQL and LINQ to Excel post of 12/3/2008. Eric explains:

This can enable some interesting scenarios – let’s say that you have a database that contains some sort of master records, and you’ve downloaded another table and significantly modified it through one means or another. Without using this technique, you would either need to a) upload your modified records into a temporary table, or b) export the master records in some fashion. However, by combining LINQ to SQL with LINQ to Objects in this fashion, you can write some pretty simple C# code that uses LINQ to join data across two separate, disparate data sources.

His post includes a link to download the sample code, which uses Northwind’s Customers table as a data source. This is another example of Microsoft evangelists preference for LINQ to SQL over EF.

Eyal Lantzman’s Sculpture - Model-Driven Development code generation framework post of 12/2/2008 reports the availability of the open-source Sculpture 1.0 Beta 2 code generator from CodePlex. According to the coordinators, Sculpture 1.0 Beta 2 has the following ready-made molds (templates):

    • For Data Source Layer:
      • SQL Server.
    • For Data Access Layer:
      • DAAB (Data Access Application Block).
      • NHibernate.
      • LINQ to SQL.
      • CSLA framework.
    • For Service Layer:
      • Service Library.
      • ASMX (ASP.NET Web Service).
      • WCF (Windows Communication Foundation).
    • For User Interface Layer:
      • Windows Forms.
      • WPF (Windows Presentation Foundation)
      • Silverlight.
      • ASP.NET.
      • ASP.NET MVC.

[Emphasis added.]

Natthawut Kulnirundorn demonstrates how to use DbLinq with LINQ to SQL to change the data source from SQL Server to My SQL in his LINQ with MySQL post of 11/30/2008 (it just showed up on Technorati.) According to Natthawut:

However, the project is still at its very beginning stage and I think it will take some time before we can use it in production environment, IMHO.

See the ADO.NET Team’s Migrating from LINQ to SQL to the Entity Framework: Stored Procedures for data retrieval post in the EF/EDM topic above.

LINQ to Objects, LINQ to XML, et al.

Michael Friis announces in his LinqtoCRM 0.3.0 released post of 12/6/2008 that v0.3.0 of his LINQ to CRM provider for Microsoft Dynamics CRM (4.0) is available for download from CodePlex. According to Michael, LINQ to CRM offers the following features:

  • Where-clauses of some complexity (And/Or, greater/less-than etc.)
  • Joins through relationtionships
  • Translation of queries to FetchXML
  • Parsing of result to anonymous types or CRM entities
  • Orderby
  • Skip/Take
  • Count
  • Contains, StartsWith, EndsWith
  • CRMMetal tool for generating ManyToMany relationship classes

You can watch a four-minute “getting started” screencast here.

Eric White describes code to join SQL Server 2000+ tables to Excel 2007 worksheets in his Joining LINQ to SQL and LINQ to Excel post of 12/3/2008. See the entry in the LINQ to SQL section for more details.

Sreedhar Vengala’s Linq to Objects - A 5 minute overview of 12/1/2008 is an introduction to LINQ for absolute beginners. His Lambda One-Liner or LINQ post of the same date shows how to convert a List<A> to List<B> with a single-line lambda expression or a LINQ query expression wrapped with the ToList<B> function.

ADO.NET Data Services (Astoria)

Andy Conrad’s Developing anAstoria data provider for SubSonic post of 12/5/2008 describes his newly released project as follows:

I have developed a data provider for SubSonic to enable it as a ADO.NET Data Services data source. This ended up being a bit harder then I initially thought, and is definitely still a work in progress. If you are interested, I have started a code gallery project for it.

Gil Fink explains Eager Loading and Lazy Loading in ADO.NET Data Services in this post of 12/5/2008.

Gil Fink shows you how easy it is in his brief Building a Host for ADO.NET Data Service[s] post of 12/3/2008. He also posted a link to his slide deck (in English) and sample code for his recent presentation to the Israel Visual Basic User Group in ADO.NET Data Services Slide Deck.

Marcello Lopez Ruiz’s Depth vs. width in ADO.NET Data Services $expand post of 12/1/2008 explains the syntax of the $expand option for many:one, one:many, and both relationships for a given parent collection.

ASP.NET Dynamic Data (DD)

Steve Naughton demonstrates in his Dynamic Data – Registering Multiple Models post of 12/7/2008 two ways to enable multiple DataContexts or ObjectContexts in DD sites:

  1. Register Multiple DataContexts with the default Model.
  2. Register each DataContext with it’s own Model.

Although Steve says “And here’s the download” at the end of the post, there’s no link.

Steve Naughton’s Dynamic Data - Updated URL FieldTemplate post of 12/2/2008 shows you how to change DD Future’s URL FieldTemplate to display link text instead of the URL in a list box. 

Scott Guthrie lists recent posts about ASP.NET Dynamic Data, as well as other ASP.NET topics, in his Dec 2nd Links: ASP.NET, ASP.NET Dynamic Data, ASP.NET AJAX, ASP.NET MVC, Visual Studio, Silverlight/WPF linkblog post of 12/2/2008.

SQL Data Services (SDS) and Cloud Computing

••• Steve Marx describes new Twitter functionality for his Azure-based blog in his Windows Azure to Twitter and Back post of 12/7/2008. Check out the list of the five latest tweets, which include an autogenerated tweet for each new post. (I use TwitterFeed.)

 InformationWeek posted on 12/6/2008 a seven-page How-To Guide To Cloud Computing by Adam Ely, David Berlind, J. Nicholas Hoover, and John Foley, which will be published 12/8/2008.

••• Roger Jennings gets bitten by moving-target SimpleDB attributes and explains how to avoid the problem in his Attempts to Cure SimpleDB’s Scrambled Attribute Disease post of 12/5/2008 (updated 12/6/2008.)

••• Eugenio Pace delivers the first chapter of his promised Architecting Cloud Applications for the Enterprise series with Part I - Introducing the Actors of 12/5/2008, which provides the cast of characters: VeryBigCorp (VBC), SuperCloudySoftware, a “cloud ISV”, and IssueTracker, a multi-tenant application for (what else?) tracking issues.

••• Kevin Hoffman posted his concerns about Not-so-secret keys and passwords in a SQL Data Services (SDS) - Getting Started forum thread on 12/5/2008. Microsoft’s George Moore responded:

Unless you have some form of secure storage on your local client where your secret keys can be held (such as this USB key fob) for an appropriate cert exchange, then there's no true security unless you move the keys off the client.  And hence the "gatekeeper" security pattern discussed above.

Client side access of trusted code is Hard Problem, unless, of course, you move the code off the local client.

••• Jim Nakashima Updated: Walkthrough on Deploying a Cloud Service (on Windows Azure) on 12/5/2008. Jim says:

Hopefully it provides more clarity into when you should use the various endpoints ( versus for example) and is a little more concise on some of the terminology.

Mike Amundsen started the I thought we could store Entities with more than one property with the same name thread in the SQL Data Services (SDS) - Getting Started forum on 12/5/2008 and learned from Anil Reddy that:

We’ve never supported the storage of “multi-valued fields” – singletons only.   However we should be returning an error in this case since we’re silently dropping data from the payload.

••• Joe Beernink wonders if Custom Configuration By Environment is possible in a SQL Data Services (SDS) - Getting Started forum thread on 12/4/2008. Aleks Gershaft responds:

You can have different storage accounts used for staging and production. At the current time, you can create 2 storage accounts with a single token. So you can use one storage account for test/staging, while another one for production. You can select between them using the ACS setting, which can be changed without requiring a new deployment.

And explains how “ACS settings could also be used to separate the production and staging versions of the same application as well.”

David Pallman posted the source code for his Whatsup sample Azure cloud application to CodePlex on November 8. (I just ran across it.) He describes the app as:

It is a simple web page where you enter your name and status (what you are doing right now) and see the status of others. Similar to what you see in more deluxe form on site like Facebook.

Whatsup is a "Web Role" cloud service project, consisting of an ASP.NET front end. It stores and queries status info using SQL Data Services (SDS).

You can use Whatsup with any Azure account - specify your credentials (username, password) and SDS specifics (authority container) in the Web.Config file, publish to the cloud, and you're good to go.

Roger Jennings reports an outage of SimpleDB while he was in the midst of enhancing a test harness in his SimpleDB Drops Dead at ~1:45 PM PST on 12/4/2008 of 12/4/2008. ListDomainRequest(), CreateDomainRequest(), and DeleteDomainRequest() from the C# library were still unavailable as of 4:45 PM PST. Cloud computing blots its copybook again.

• Deepak Singh, a business development manager at Amazon Web Services (AWS), announced in his Paging Researchers, Analysts, and Developers post of 12/4/2008 the availability of Public Data Sets on AWS. Deepak says:

Public Data Sets on AWS provides a convenient way to share, access, and consume publicly available data within your Amazon EC2 environment. Here is how it works

  • Select public data sets will be hosted by Amazon Web Services for free as an Amazon EBS snapshot.
  • You can access the data by creating your own personal Amazon EBS volume from a publicly shared Amazon EBS public data set snapshot.
  • You can then access, modify, and perform computations on these data sets directly using an Amazon EC2 instance and just pay for the compute and storage resources that you use.

Goilaswati asks for an explanation of the Difference between Azure Storage and SDS Storage in a 12/4/2008 thread in the Windows Azure forum. Microsoft’s Aleks Gershat replied:

There was a similar thread in SDS forum:
"SDS will provide scalable relational database as a service (today, Joins, OrderBy, Top...are supported) and as it evolves, we plan to support other features such as aggregates, schemas, fan-out queries, and so on.  SDS just like any other database also supports blobs.  SDS is for Unstructured, Semi, and Structured data, with a roadmap of having highly available relational capabilities."

This response appears to me to avoid the question of whether SDS storage is built on Azure Table Services. I believe it is.

• John Watte, an XNA/DirectX MVP, explains why his employer chose not to adopt Azure, Amazon EC2 or Google App Engine in his Why we won't be going with Azure thread of 12/3/2008 in the Windows Azure forum. The responses in the thread throw more light on the differences among cloud computing offerings.

Eugenio Pace discusses what Microsoft’s cloud architects have been up to recently and reminisces about problems with his Azure demos for the PDC 2008 SYMP05 - Services Symposium: Enterprise Grade Cloud Applications session in his Architecting Cloud Services for the Big Enterprise post of 12/4/2008. Eugenio says:

For the last couple of months, we’ve been working on scenarios that involve consuming cloud services and applications from "Big Enterprise". The focus being the technical obstacles for adopting cloud services.

Big Enterprise is the moniker we use to describe an organization with rather heavy investments on on-premises software. …

Since PDC, we’ve been working on improving the reference implementations our demos were based on, by incorporating all this experience: obscure pitfalls, wrong assumptions, unexpected limitations, lack of complete symmetry between production and pre-production, pure randomness, etc. …

My plan is to drill down on each of these aspects in the next (several) couple of blog posts, so stay tuned!

Last but not least, most of the sample code demonstrated will be available for you to download and explore in the upcoming weeks.

I’ll be looking forward to Eugenio fulfilling his promises for reference implementations and related sample code.

Jim Nakashima’s Creating Tables post of 12/3/2008 announces that his Simple Table Storage sample has adopted Steve Marx’s approach to creating tables only once, as described in Steve’s Try to Create Tables Only Once post of 11/18/2008. My Azure Table Services test harness uses Steve’s technique.

Kapil Gupta reports Problem with SDS SSIS connectivity in his 12/3/2008 thread in the SQL Data Services (SDS) - Getting Started forum. According to Microsoft’s Matt Mason:

You'll want to get the latest binaries from the Codeplex project. They were updated November 18th to target the new service URL.
A new URL property has also been added to the Connection Manager, incase you need to point to a new service URL in the future.

Kapil notes that currently you must select the SQL Server Data Services Source and Destination link (Sep 24, 2008, Beta) because the release date hasn’t been updated to 11/18/2008

John Folye’s Impeaches Amazon Web Services post of 12/3/2008 describes the Politicker political Web site’s dissatisfaction with AWS EC2 and its return to dedicated hosted services from Voxel.

As I see it, Windows Azure’s goal is to eliminate the administrative headaches that hampered Politicker’s EC2 usage in high-traffic environments in favor of increased automation of scale-up and scale-out operations.

Mike Manos describes Microsoft’s new datacenter design and deployment in his Our Vision for Generation 4 Modular Data Centers - One way of Getting it just right . . . post of 12/2/2008. The post concentrates on the new modular, containerized data center that Microsoft’s constructing in Chicago.

Vollynerd asks if Table/Blob/Queue storage - REST APIs the only available? in a Windows Azure Forum post of 12/1/2008. Microsoft Daniel C. Wang replies:

The only exposed interfaces for the CTP is the REST protocol. We provide the StorageClient library as an example wrapper, but there is no lower-level interface exposed for the CTP.

Hopefully, the Azure Data Services team will enable a simpler, low-overhead protocol and client wrapper in beta drops, especially for use on deployed projects.

Jeff Barr’s Amazon SimpleDB Grows Up post of 12/1/2008 announces that Amazon Web Service’s SimpleDB database service has moved from private to public beta status with a substantial reduction in data storage fees (from $1.50/GB-month down to $0.25/GB-month). Jeff says:

We've made the business decision to go with SimpleDB even simpler than it was before. You can now get started for free. For at least the next six months, you can consume up to 500 MB of storage, and you can use up to 25 machine hours each month. You can transfer 1 GB of data in, and another 1 GB out. You can move as much data to and from Amazon EC2 as you would like, for free.

I’m in the process of writing and testing an ASP.NET test harness for SimpleDB that emulates the Azure test harness described in my seven-part Azure Storage Services Test Harness series. Currently, I’m testing it locally, which emulates the Azure version’s local Web hosting with Azure data.  Later this week, I’ll test hosting the ASP.NET project on EC2, which very closely resembles an Azure production environment. Another version that’s hosted on EC2 and uses the EC2 instance’s SQL Server Express engine as the data source is operational.

(Above repeated from the 11/24/2008 post)

Amazon announced the following new SimpleDB features that will be forthcoming “in the next few weeks:”

  • SQL-like SELECT API: With this feature, you will be able to employ a very familiar SQL-like query language when constructing queries and building applications. The SELECT API will help you be more productive with Amazon SimpleDB right from the start.
  • Batch Put: Enables you to streamline the upload of multiple items or attributes, with a single batch API request rather than multiple single item calls.

I would expect batched PUT operations would greatly improve the current slow upload times for simple entities.

Zoho Corp’s announced its new CloudSQL middleware in a recent The Future of SQL in a SaaS world: Announcing Zoho CloudSQL post and Access Business Data in the Cloud Through SQL white paper. CloudSQL offers features like SimpleDB’s SELECT API for Zoho Reports with a JDBC driver and entity mapping. The firm plans to extend CloudSQL to other Zoho services, as well as offer ODBC and REST drivers.

SQL Server Compact (SSCE) 3.5 and Sync Services

No significant posts as of 12/7/2008, 8:30 AM PST 

Miscellaneous (WPF, WCF, MVC, Silverlight, etc.)

Rob Conery bites the DDD bullet in his MVC Storefront Part 25: Getting Started With Domain-Driven Design post of 12/5/2008 that includes a link to a 42-minute (!) screen cast.


Anonymous said...

Hi Roger,

Thanks for the post on my MSDN Magazine article. One thing I would like to highlight is that it describes a soluton for tracking changes across service boundaries. Although Entity Framework v. 2 will enhance the experience, the nice thing is that the article shows how to accomlish this feat today. :)

BTW, I am starting to write more blog posts on L2S and EF, which might interest readers of your blog.

Keep up the good work!


P.S. I also teach a course on LINQ and the Entity Framework for DevelopMentor.