<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Steve Morgan - Technology Spot</title><link>http://hastobe.net/blogs/stevemorgan/default.aspx</link><description>A tour through the rambling mind of a life-long techie.</description><dc:language>en</dc:language><generator>CommunityServer 2008 SP1 (Build: 30619.63)</generator><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/hastobedotnet" /><feedburner:info uri="hastobedotnet" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item><title>Writing about the Cloud for PlatformCloud9</title><link>http://feedproxy.google.com/~r/hastobedotnet/~3/S0pa9B1llaY/writing-about-the-cloud-for-platformcloud9.aspx</link><pubDate>Thu, 08 Mar 2012 19:08:00 GMT</pubDate><guid isPermaLink="false">b3b1d9c2-f4c9-4970-bb5d-c90d4bed0aec:585</guid><dc:creator>Steve Morgan</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;I was recently invited, through work, to start writing about the technical side of designing and developing applications for the cloud on &lt;a target="_blank" title="Link to PlatformCloud9.com" href="http://www.platformcloud9.com/"&gt;PlatformCloud9.com&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" title="Link to PlatformCloud9.com" href="http://www.platformcloud9.com/"&gt;PlatformCloud9&lt;/a&gt; is an industry-specific site from the editorial team from &lt;a target="_blank" title="Link to BusinessCloud9.com" href="http://www.businesscloud9.com"&gt;BusinessCloud9.com&lt;/a&gt; and is expected to launch soon (at the time of writing, at least). I&amp;#39;ve started with some articles on developing multi-tenant applications for Windows Azure. While the &lt;a target="_blank" title="Link to PlatformCloud9.com" href="http://www.platformcloud9.com/"&gt;PlatformCloud9&lt;/a&gt; site is being established, those articles will appear on &lt;a target="_blank" title="Link to my blog on BusinessCloud9.com" href="http://www.businesscloud9.com/users/steve-morgan"&gt;BusinessCloud9&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" title="Link to BusinessCloud9.com" href="http://www.businesscloud9.com"&gt;BusinessCloud9&lt;/a&gt; is a well-respected site with insight into cloud computing from a number of experts across the IT industry. The material is typically aimed at CxO&amp;#39;s. The sister site, &lt;a target="_blank" title="Link to PlatformCloud9.com" href="http://www.platformcloud9.com/"&gt;PlatformCloud9&lt;/a&gt;, aims to build on that with guidance of an more technical nature from subject matter experts with hands-on experience actually delivering cloud-based solutions.&lt;/p&gt;
&lt;p&gt;It&amp;#39;s a great opportunity for me. As you&amp;#39;ll see, my posts here have been extremely sporadic. Writing for the site gives me a great incentive to knuckle down and create some interesting new posts. The feedback I&amp;#39;ve had so far has been extremely encouraging. The exposure I gain is no bad thing, either.&lt;/p&gt;
&lt;p&gt;A less fortunate consequence is that I&amp;#39;m likely to be posting here even &lt;i&gt;more&lt;/i&gt; sporadically; if such a thing was possible. But please join me over at &lt;a target="_blank" title="Link to PlatformCloud9.com" href="http://www.platformcloud9.com/"&gt;PlatformCloud9&lt;/a&gt; or &lt;a target="_blank" title="Link to my blog on BusinessCloud9.com" href="http://www.businesscloud9.com/users/steve-morgan"&gt;BusinessCloud9&lt;/a&gt; and hopefully you&amp;#39;ll find something of interest.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://hastobe.net/aggbug.aspx?PostID=585" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=S0pa9B1llaY:Wtzkd-q7mm4:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=S0pa9B1llaY:Wtzkd-q7mm4:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?i=S0pa9B1llaY:Wtzkd-q7mm4:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=S0pa9B1llaY:Wtzkd-q7mm4:l6gmwiTKsz0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?d=l6gmwiTKsz0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=S0pa9B1llaY:Wtzkd-q7mm4:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=S0pa9B1llaY:Wtzkd-q7mm4:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?i=S0pa9B1llaY:Wtzkd-q7mm4:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=S0pa9B1llaY:Wtzkd-q7mm4:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?i=S0pa9B1llaY:Wtzkd-q7mm4:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/hastobedotnet/~4/S0pa9B1llaY" height="1" width="1"/&gt;</description><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Windows+Azure/default.aspx">Windows Azure</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Cloud/default.aspx">Cloud</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Industry/default.aspx">Industry</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Development/default.aspx">Development</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Writing/default.aspx">Writing</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/PlatformCloud9/default.aspx">PlatformCloud9</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/BusinessCloud9/default.aspx">BusinessCloud9</category><feedburner:origLink>http://hastobe.net/blogs/stevemorgan/archive/2012/03/08/writing-about-the-cloud-for-platformcloud9.aspx</feedburner:origLink></item><item><title>Howto: Use ASP.NET SQL Server Session State Provider with Entity Framework Code-First with SQL Azure - Part II</title><link>http://feedproxy.google.com/~r/hastobedotnet/~3/mpfCRjztXjU/howto-use-asp-net-sql-server-session-state-provider-with-entity-framework-code-first-with-sql-azure-part-ii.aspx</link><pubDate>Fri, 12 Aug 2011 08:22:00 GMT</pubDate><guid isPermaLink="false">b3b1d9c2-f4c9-4970-bb5d-c90d4bed0aec:509</guid><dc:creator>Steve Morgan</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://hastobe.net/blogs/stevemorgan/rsscomments.aspx?PostID=509</wfw:commentRss><comments>http://hastobe.net/blogs/stevemorgan/archive/2011/08/12/howto-use-asp-net-sql-server-session-state-provider-with-entity-framework-code-first-with-sql-azure-part-ii.aspx#comments</comments><description>&lt;p&gt;This is the second and final part of a two-part post. In &lt;a target="_self" href="http://hastobe.net/blogs/stevemorgan/archive/2011/08/11/howto-use-asp-net-sql-server-session-state-provider-with-entity-framework-code-first-with-sql-azure.aspx" title="Link to Part I of this two-part post"&gt;Part I&lt;/a&gt;, I described some of the issues with combining EF Code-First and ASP.NET SQL Server Session State in the same database and by the end of the article, I&amp;#39;d described how I&amp;#39;d got Entity Framework managing the two tables that support the SQL Server Session State Provider.&lt;/p&gt;
&lt;p&gt;All access to the state database is implemented using a significant number of SQL Server Stored Procedures. Stored procs seem to be falling out of favour, as developers put their faith in abstraction layers such as Entity Framework to magically infer the best way to interact with their data. I&amp;#39;m still a big fan of stored procs and &lt;a target="_blank" href="http://stackoverflow.com/questions/417898/why-do-i-need-stored-procedures-when-i-have-linq-to-sql/417957#417957" title="Question on StackOverflow.com"&gt;despite arguments to the contrary&lt;/a&gt;, my experience suggests that I&amp;#39;m better at optimising data access that EF is. An unfortunate consequence is that, in certain areas (and so far, I see EF Code-First as one of them), stored procs are very much under-supported. The Reverse Engineer Code First Power Tool that I described in &lt;a href="http://hastobe.net/blogs/stevemorgan/archive/2011/08/11/howto-use-asp-net-sql-server-session-state-provider-with-entity-framework-code-first-with-sql-azure.aspx" title="Link to Part I"&gt;Part I&lt;/a&gt; will happily reverse-engineer your database tables, but gives no consideration to those all-important stored procedures. As a consequence, when EF recreates the database, it will create the state tables, but no stored procs to accompany them. That just won&amp;#39;t do.&lt;/p&gt;
&lt;p&gt;The approach I took was to get Entity Framework to automatically create the stored procedures when it recreated the database. The magic is in an Initializer class; in this case called SchoolInitializer. Here&amp;#39;s the original source of that class, with various lines of database population code removed for brevity:&lt;/p&gt;
&lt;pre style="color:#000020;background:#f6f8ff;"&gt;&lt;span style="font-weight:bold;color:#200080;"&gt;public&lt;/span&gt; &lt;span style="font-weight:bold;color:#200080;"&gt;class&lt;/span&gt; SchoolInitializer &lt;span style="color:#308080;"&gt;:&lt;/span&gt; DropCreateDatabaseIfModelChanges&lt;span style="color:#308080;"&gt;&amp;lt;&lt;/span&gt;SchoolContext&lt;span style="color:#308080;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="color:#406080;"&gt;{&lt;/span&gt;
    &lt;span style="font-weight:bold;color:#200080;"&gt;protected&lt;/span&gt; &lt;span style="font-weight:bold;color:#200080;"&gt;override&lt;/span&gt; &lt;span style="font-weight:bold;color:#200080;"&gt;void&lt;/span&gt; Seed&lt;span style="color:#308080;"&gt;(&lt;/span&gt;SchoolContext context&lt;span style="color:#308080;"&gt;)&lt;/span&gt;
    &lt;span style="color:#406080;"&gt;{&lt;/span&gt;
        var students &lt;span style="color:#308080;"&gt;=&lt;/span&gt; &lt;span style="font-weight:bold;color:#200080;"&gt;new&lt;/span&gt; List&lt;span style="color:#308080;"&gt;&amp;lt;&lt;/span&gt;Student&lt;span style="color:#308080;"&gt;&amp;gt;&lt;/span&gt;
        &lt;span style="color:#406080;"&gt;{&lt;/span&gt;
            &lt;span style="font-weight:bold;color:#200080;"&gt;new&lt;/span&gt; Student &lt;span style="color:#406080;"&gt;{&lt;/span&gt; FirstMidName &lt;span style="color:#308080;"&gt;=&lt;/span&gt; &lt;span style="color:#800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#1060b6;"&gt;Carson&lt;/span&gt;&lt;span style="color:#800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#308080;"&gt;,&lt;/span&gt;   LastName &lt;span style="color:#308080;"&gt;=&lt;/span&gt; &lt;span style="color:#800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#1060b6;"&gt;Alexander&lt;/span&gt;&lt;span style="color:#800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#308080;"&gt;,&lt;/span&gt; EnrollmentDate &lt;span style="color:#308080;"&gt;=&lt;/span&gt; DateTime&lt;span style="color:#308080;"&gt;.&lt;/span&gt;Parse&lt;span style="color:#308080;"&gt;(&lt;/span&gt;&lt;span style="color:#800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#1060b6;"&gt;2005-09-01&lt;/span&gt;&lt;span style="color:#800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt; &lt;span style="color:#406080;"&gt;}&lt;/span&gt;&lt;span style="color:#308080;"&gt;,&lt;/span&gt;
            &lt;span style="font-weight:bold;color:#200080;"&gt;new&lt;/span&gt; Student &lt;span style="color:#406080;"&gt;{&lt;/span&gt; FirstMidName &lt;span style="color:#308080;"&gt;=&lt;/span&gt; &lt;span style="color:#800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#1060b6;"&gt;Meredith&lt;/span&gt;&lt;span style="color:#800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#308080;"&gt;,&lt;/span&gt; LastName &lt;span style="color:#308080;"&gt;=&lt;/span&gt; &lt;span style="color:#800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#1060b6;"&gt;Alonso&lt;/span&gt;&lt;span style="color:#800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#308080;"&gt;,&lt;/span&gt;    EnrollmentDate &lt;span style="color:#308080;"&gt;=&lt;/span&gt; DateTime&lt;span style="color:#308080;"&gt;.&lt;/span&gt;Parse&lt;span style="color:#308080;"&gt;(&lt;/span&gt;&lt;span style="color:#800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#1060b6;"&gt;2002-09-01&lt;/span&gt;&lt;span style="color:#800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt; &lt;span style="color:#406080;"&gt;}&lt;/span&gt;
        &lt;span style="color:#406080;"&gt;}&lt;/span&gt;&lt;span style="color:#406080;"&gt;;&lt;/span&gt;
        students&lt;span style="color:#308080;"&gt;.&lt;/span&gt;ForEach&lt;span style="color:#308080;"&gt;(&lt;/span&gt;s &lt;span style="color:#308080;"&gt;=&lt;/span&gt;&lt;span style="color:#308080;"&gt;&amp;gt;&lt;/span&gt; context&lt;span style="color:#308080;"&gt;.&lt;/span&gt;Students&lt;span style="color:#308080;"&gt;.&lt;/span&gt;Add&lt;span style="color:#308080;"&gt;(&lt;/span&gt;s&lt;span style="color:#308080;"&gt;)&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt;&lt;span style="color:#406080;"&gt;;&lt;/span&gt;
        context&lt;span style="color:#308080;"&gt;.&lt;/span&gt;SaveChanges&lt;span style="color:#308080;"&gt;(&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt;&lt;span style="color:#406080;"&gt;;&lt;/span&gt;

        &lt;span style="color:#595979;"&gt;// Other content removed for brevity&lt;/span&gt;
    &lt;span style="color:#406080;"&gt;}&lt;/span&gt;
&lt;span style="color:#406080;"&gt;}&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;There are two points of note, here. Firstly, SchoolInitializer is derived from DropCreateDatabaseIfModelChanges&amp;lt;SchoolContext&amp;gt;. This tells EF to automatically recreate the database if the model associated with the context changes in code. That&amp;#39;s not a bad approach for Development and Test environments (a bit risky for Production ones, though). The problem at this point is that it relies on the presence of a table in the database called EdmMetadata and as our database only has the ASP State tables in it at the moment, it will fail.&lt;/p&gt;
&lt;p&gt;Secondly, the Seed() method is called to populate the database with initial data&amp;nbsp;when it is recreated. The example uses this method to add test data. I shall use the method to solve my&amp;nbsp;stored procedure problem... (I should&amp;nbsp;say, there may well be a better place to&amp;nbsp;do this,&amp;nbsp;but it&amp;#39;ll do for now).&lt;/p&gt;
&lt;p&gt;I decided to approach the problem by having&amp;nbsp;the Seed() method run a SQL script to generate the stored procs. I have a SQL script, of course, which is the &lt;a href="http://hastobe.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/stevemorgan/InstallSqlState.SQL" title="InstallSqlState.SQL script"&gt;InstallSqlState.SQL&lt;/a&gt; script that I used originally to create the ASP State tables.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;There are some changes required, though...&lt;/p&gt;
&lt;p&gt;Firstly, I needed to remove the script that created the ASP state tables. EF takes care of those, now.&lt;/p&gt;
&lt;p&gt;The next problem got me scratching my head for a few minutes, though. The ASPStateTempSessions table makes use of default values for a couple of its columns:&lt;/p&gt;
&lt;pre style="color:#000020;background:#f6f8ff;"&gt;&lt;span style="font-weight:bold;color:#200080;"&gt;CREATE&lt;/span&gt; &lt;span style="font-weight:bold;color:#200080;"&gt;TABLE&lt;/span&gt; dbo&lt;span style="color:#308080;"&gt;.&lt;/span&gt;ASPStateTempSessions &lt;span style="color:#308080;"&gt;(&lt;/span&gt;
    SessionId        nvarchar&lt;span style="color:#308080;"&gt;(&lt;/span&gt;&lt;span style="color:#008c00;"&gt;88&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt;    &lt;span style="font-weight:bold;color:#200080;"&gt;NOT&lt;/span&gt; &lt;span style="font-weight:bold;color:#200080;"&gt;NULL&lt;/span&gt; &lt;span style="font-weight:bold;color:#200080;"&gt;PRIMARY&lt;/span&gt; &lt;span style="font-weight:bold;color:#200080;"&gt;KEY&lt;/span&gt;&lt;span style="color:#308080;"&gt;,&lt;/span&gt;
    Created          datetime        &lt;span style="font-weight:bold;color:#200080;"&gt;NOT&lt;/span&gt; &lt;span style="font-weight:bold;color:#200080;"&gt;NULL&lt;/span&gt; &lt;span style="font-weight:bold;color:#200080;"&gt;DEFAULT&lt;/span&gt; GETUTCDATE&lt;span style="color:#308080;"&gt;(&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt;&lt;span style="color:#308080;"&gt;,&lt;/span&gt;
    Expires          datetime        &lt;span style="font-weight:bold;color:#200080;"&gt;NOT&lt;/span&gt; &lt;span style="font-weight:bold;color:#200080;"&gt;NULL&lt;/span&gt;&lt;span style="color:#308080;"&gt;,&lt;/span&gt;
    LockDate         datetime        &lt;span style="font-weight:bold;color:#200080;"&gt;NOT&lt;/span&gt; &lt;span style="font-weight:bold;color:#200080;"&gt;NULL&lt;/span&gt;&lt;span style="color:#308080;"&gt;,&lt;/span&gt;
    LockDateLocal    datetime        &lt;span style="font-weight:bold;color:#200080;"&gt;NOT&lt;/span&gt; &lt;span style="font-weight:bold;color:#200080;"&gt;NULL&lt;/span&gt;&lt;span style="color:#308080;"&gt;,&lt;/span&gt;
    LockCookie       &lt;span style="font-weight:bold;color:#200080;"&gt;int&lt;/span&gt;             &lt;span style="font-weight:bold;color:#200080;"&gt;NOT&lt;/span&gt; &lt;span style="font-weight:bold;color:#200080;"&gt;NULL&lt;/span&gt;&lt;span style="color:#308080;"&gt;,&lt;/span&gt;
    &lt;span style="font-weight:bold;color:#200080;"&gt;Timeout&lt;/span&gt;          &lt;span style="font-weight:bold;color:#200080;"&gt;int&lt;/span&gt;             &lt;span style="font-weight:bold;color:#200080;"&gt;NOT&lt;/span&gt; &lt;span style="font-weight:bold;color:#200080;"&gt;NULL&lt;/span&gt;&lt;span style="color:#308080;"&gt;,&lt;/span&gt;
    &lt;span style="font-weight:bold;color:#200080;"&gt;Locked&lt;/span&gt;           &lt;span style="font-weight:bold;color:#200080;"&gt;bit&lt;/span&gt;             &lt;span style="font-weight:bold;color:#200080;"&gt;NOT&lt;/span&gt; &lt;span style="font-weight:bold;color:#200080;"&gt;NULL&lt;/span&gt;&lt;span style="color:#308080;"&gt;,&lt;/span&gt;
    SessionItemShort VARBINARY&lt;span style="color:#308080;"&gt;(&lt;/span&gt;&lt;span style="color:#008c00;"&gt;7000&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt; &lt;span style="font-weight:bold;color:#200080;"&gt;NULL&lt;/span&gt;&lt;span style="color:#308080;"&gt;,&lt;/span&gt;
    SessionItemLong  image           &lt;span style="font-weight:bold;color:#200080;"&gt;NULL&lt;/span&gt;&lt;span style="color:#308080;"&gt;,&lt;/span&gt;
    Flags            &lt;span style="font-weight:bold;color:#200080;"&gt;int&lt;/span&gt;             &lt;span style="font-weight:bold;color:#200080;"&gt;NOT&lt;/span&gt; &lt;span style="font-weight:bold;color:#200080;"&gt;NULL&lt;/span&gt; &lt;span style="font-weight:bold;color:#200080;"&gt;DEFAULT&lt;/span&gt; &lt;span style="color:#008c00;"&gt;0&lt;/span&gt;&lt;span style="color:#308080;"&gt;,&lt;/span&gt;
&lt;span style="color:#308080;"&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;Note the use of DEFAULT GETUTCDATE() for the Created column and DEFAULT 0 for Flags. The problem here is that EF is now responsible for creating our tables&amp;nbsp;but EF and default values&amp;nbsp;do not make happy bed fellows. Fortunately, the solution was simple enough. I updated the stored procs to explicitly supply the values instead of relying on the presence of the defaults. There&amp;#39;s another point&amp;nbsp;in favour of&amp;nbsp;stored procedures!&lt;/p&gt;
&lt;p&gt;As an example, this stored procedure:&lt;/p&gt;
&lt;pre style="color:#000020;background:#f6f8ff;"&gt;&lt;span style="font-weight:bold;color:#200080;"&gt;CREATE&lt;/span&gt; &lt;span style="font-weight:bold;color:#200080;"&gt;PROCEDURE&lt;/span&gt; dbo&lt;span style="color:#308080;"&gt;.&lt;/span&gt;TempInsertStateItemLong
    &lt;span style="color:#007d45;"&gt;@id&lt;/span&gt;         nvarchar&lt;span style="color:#308080;"&gt;(&lt;/span&gt;&lt;span style="color:#008c00;"&gt;88&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt;&lt;span style="color:#308080;"&gt;,&lt;/span&gt;
    &lt;span style="color:#007d45;"&gt;@itemLong&lt;/span&gt;  image&lt;span style="color:#308080;"&gt;,&lt;/span&gt;
    &lt;span style="color:#007d45;"&gt;@timeout&lt;/span&gt;    &lt;span style="font-weight:bold;color:#200080;"&gt;int&lt;/span&gt;
&lt;span style="font-weight:bold;color:#200080;"&gt;AS&lt;/span&gt;    
    &lt;span style="font-weight:bold;color:#200080;"&gt;DECLARE&lt;/span&gt; &lt;span style="color:#007d45;"&gt;@now&lt;/span&gt; &lt;span style="font-weight:bold;color:#200080;"&gt;AS&lt;/span&gt; datetime
    &lt;span style="font-weight:bold;color:#200080;"&gt;DECLARE&lt;/span&gt; &lt;span style="color:#007d45;"&gt;@nowLocal&lt;/span&gt; &lt;span style="font-weight:bold;color:#200080;"&gt;AS&lt;/span&gt; datetime
    
    &lt;span style="font-weight:bold;color:#200080;"&gt;SET&lt;/span&gt; &lt;span style="color:#007d45;"&gt;@now&lt;/span&gt; &lt;span style="color:#308080;"&gt;=&lt;/span&gt; GETUTCDATE&lt;span style="color:#308080;"&gt;(&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt;
    &lt;span style="font-weight:bold;color:#200080;"&gt;SET&lt;/span&gt; &lt;span style="color:#007d45;"&gt;@nowLocal&lt;/span&gt; &lt;span style="color:#308080;"&gt;=&lt;/span&gt; &lt;span style="font-weight:bold;color:#7779bb;"&gt;GETDATE&lt;/span&gt;&lt;span style="color:#308080;"&gt;(&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt;

    &lt;span style="font-weight:bold;color:#200080;"&gt;INSERT&lt;/span&gt; dbo&lt;span style="color:#308080;"&gt;.&lt;/span&gt;ASPStateTempSessions 
        &lt;span style="color:#308080;"&gt;(&lt;/span&gt;SessionId&lt;span style="color:#308080;"&gt;,&lt;/span&gt; 
         SessionItemLong&lt;span style="color:#308080;"&gt;,&lt;/span&gt; 
         &lt;span style="font-weight:bold;color:#200080;"&gt;Timeout&lt;/span&gt;&lt;span style="color:#308080;"&gt;,&lt;/span&gt; 
         Expires&lt;span style="color:#308080;"&gt;,&lt;/span&gt; 
         &lt;span style="font-weight:bold;color:#200080;"&gt;Locked&lt;/span&gt;&lt;span style="color:#308080;"&gt;,&lt;/span&gt; 
         LockDate&lt;span style="color:#308080;"&gt;,&lt;/span&gt;
         LockDateLocal&lt;span style="color:#308080;"&gt;,&lt;/span&gt;
         LockCookie&lt;span style="color:#308080;"&gt;)&lt;/span&gt; 
    &lt;span style="font-weight:bold;color:#200080;"&gt;VALUES&lt;/span&gt; 
        &lt;span style="color:#308080;"&gt;(&lt;/span&gt;&lt;span style="color:#007d45;"&gt;@id&lt;/span&gt;&lt;span style="color:#308080;"&gt;,&lt;/span&gt; 
         &lt;span style="color:#007d45;"&gt;@itemLong&lt;/span&gt;&lt;span style="color:#308080;"&gt;,&lt;/span&gt; 
         &lt;span style="color:#007d45;"&gt;@timeout&lt;/span&gt;&lt;span style="color:#308080;"&gt;,&lt;/span&gt; 
         &lt;span style="font-weight:bold;color:#7779bb;"&gt;DATEADD&lt;/span&gt;&lt;span style="color:#308080;"&gt;(&lt;/span&gt;n&lt;span style="color:#308080;"&gt;,&lt;/span&gt; &lt;span style="color:#007d45;"&gt;@timeout&lt;/span&gt;&lt;span style="color:#308080;"&gt;,&lt;/span&gt; &lt;span style="color:#007d45;"&gt;@now&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt;&lt;span style="color:#308080;"&gt;,&lt;/span&gt; 
         &lt;span style="color:#008c00;"&gt;0&lt;/span&gt;&lt;span style="color:#308080;"&gt;,&lt;/span&gt; 
         &lt;span style="color:#007d45;"&gt;@now&lt;/span&gt;&lt;span style="color:#308080;"&gt;,&lt;/span&gt;
         &lt;span style="color:#007d45;"&gt;@nowLocal&lt;/span&gt;&lt;span style="color:#308080;"&gt;,&lt;/span&gt;
         &lt;span style="color:#008c00;"&gt;1&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt;

    &lt;span style="font-weight:bold;color:#200080;"&gt;RETURN&lt;/span&gt; &lt;span style="color:#008c00;"&gt;0&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;became&lt;/p&gt;
&lt;pre style="color:#000020;background:#f6f8ff;"&gt;&lt;span style="font-weight:bold;color:#200080;"&gt;CREATE&lt;/span&gt; &lt;span style="font-weight:bold;color:#200080;"&gt;PROCEDURE&lt;/span&gt; dbo&lt;span style="color:#308080;"&gt;.&lt;/span&gt;TempInsertStateItemLong
    &lt;span style="color:#007d45;"&gt;@id&lt;/span&gt;         nvarchar&lt;span style="color:#308080;"&gt;(&lt;/span&gt;&lt;span style="color:#008c00;"&gt;88&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt;&lt;span style="color:#308080;"&gt;,&lt;/span&gt;
    &lt;span style="color:#007d45;"&gt;@itemLong&lt;/span&gt;  image&lt;span style="color:#308080;"&gt;,&lt;/span&gt;
    &lt;span style="color:#007d45;"&gt;@timeout&lt;/span&gt;    &lt;span style="font-weight:bold;color:#200080;"&gt;int&lt;/span&gt;
&lt;span style="font-weight:bold;color:#200080;"&gt;AS&lt;/span&gt;    
    &lt;span style="font-weight:bold;color:#200080;"&gt;DECLARE&lt;/span&gt; &lt;span style="color:#007d45;"&gt;@now&lt;/span&gt; &lt;span style="font-weight:bold;color:#200080;"&gt;AS&lt;/span&gt; datetime
    &lt;span style="font-weight:bold;color:#200080;"&gt;DECLARE&lt;/span&gt; &lt;span style="color:#007d45;"&gt;@nowLocal&lt;/span&gt; &lt;span style="font-weight:bold;color:#200080;"&gt;AS&lt;/span&gt; datetime
    
    &lt;span style="font-weight:bold;color:#200080;"&gt;SET&lt;/span&gt; &lt;span style="color:#007d45;"&gt;@now&lt;/span&gt; &lt;span style="color:#308080;"&gt;=&lt;/span&gt; GETUTCDATE&lt;span style="color:#308080;"&gt;(&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt;
    &lt;span style="font-weight:bold;color:#200080;"&gt;SET&lt;/span&gt; &lt;span style="color:#007d45;"&gt;@nowLocal&lt;/span&gt; &lt;span style="color:#308080;"&gt;=&lt;/span&gt; &lt;span style="font-weight:bold;color:#7779bb;"&gt;GETDATE&lt;/span&gt;&lt;span style="color:#308080;"&gt;(&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt;

    &lt;span style="font-weight:bold;color:#200080;"&gt;INSERT&lt;/span&gt; dbo&lt;span style="color:#308080;"&gt;.&lt;/span&gt;ASPStateTempSessions 
        &lt;span style="color:#308080;"&gt;(&lt;/span&gt;SessionId&lt;span style="color:#308080;"&gt;,&lt;/span&gt; 
         SessionItemLong&lt;span style="color:#308080;"&gt;,&lt;/span&gt; 
         &lt;span style="font-weight:bold;color:#200080;"&gt;Timeout&lt;/span&gt;&lt;span style="color:#308080;"&gt;,&lt;/span&gt; 
         Expires&lt;span style="color:#308080;"&gt;,&lt;/span&gt; 
         &lt;span style="font-weight:bold;color:#200080;"&gt;Locked&lt;/span&gt;&lt;span style="color:#308080;"&gt;,&lt;/span&gt; 
         LockDate&lt;span style="color:#308080;"&gt;,&lt;/span&gt;
         LockDateLocal&lt;span style="color:#308080;"&gt;,&lt;/span&gt;
         LockCookie&lt;span style="color:#308080;"&gt;,&lt;/span&gt;
         Flags&lt;span style="color:#308080;"&gt;,&lt;/span&gt;
         Created&lt;span style="color:#308080;"&gt;)&lt;/span&gt; 
    &lt;span style="font-weight:bold;color:#200080;"&gt;VALUES&lt;/span&gt; 
        &lt;span style="color:#308080;"&gt;(&lt;/span&gt;&lt;span style="color:#007d45;"&gt;@id&lt;/span&gt;&lt;span style="color:#308080;"&gt;,&lt;/span&gt; 
         &lt;span style="color:#007d45;"&gt;@itemLong&lt;/span&gt;&lt;span style="color:#308080;"&gt;,&lt;/span&gt; 
         &lt;span style="color:#007d45;"&gt;@timeout&lt;/span&gt;&lt;span style="color:#308080;"&gt;,&lt;/span&gt; 
         &lt;span style="font-weight:bold;color:#7779bb;"&gt;DATEADD&lt;/span&gt;&lt;span style="color:#308080;"&gt;(&lt;/span&gt;n&lt;span style="color:#308080;"&gt;,&lt;/span&gt; &lt;span style="color:#007d45;"&gt;@timeout&lt;/span&gt;&lt;span style="color:#308080;"&gt;,&lt;/span&gt; &lt;span style="color:#007d45;"&gt;@now&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt;&lt;span style="color:#308080;"&gt;,&lt;/span&gt; 
         &lt;span style="color:#008c00;"&gt;0&lt;/span&gt;&lt;span style="color:#308080;"&gt;,&lt;/span&gt; 
         &lt;span style="color:#007d45;"&gt;@now&lt;/span&gt;&lt;span style="color:#308080;"&gt;,&lt;/span&gt;
         &lt;span style="color:#007d45;"&gt;@nowLocal&lt;/span&gt;&lt;span style="color:#308080;"&gt;,&lt;/span&gt;
         &lt;span style="color:#008c00;"&gt;1&lt;/span&gt;&lt;span style="color:#308080;"&gt;,&lt;/span&gt;
         &lt;span style="color:#008c00;"&gt;0&lt;/span&gt;&lt;span style="color:#308080;"&gt;,&lt;/span&gt;
         &lt;span style="color:#007d45;"&gt;@now&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt;

    &lt;span style="font-weight:bold;color:#200080;"&gt;RETURN&lt;/span&gt; &lt;span style="color:#008c00;"&gt;0&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;The subtle changes, for the less-than-eagle-eyed are that I now explicitly set the Flags and Created columns.&amp;nbsp;Each&amp;nbsp;insert into ASPStateTempSessions was reviewed and updated where necessary. I&amp;#39;ve provided the &lt;a href="http://hastobe.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/stevemorgan/InstallSqlStateProcs.SQL" title="SQL script to create ASP State stored procedures"&gt;updated script&lt;/a&gt; for you to download.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;The next step was to get the Seed() method to run this updated SQL script whenever the database was created. There&amp;#39;s a complication to running SQL scripts from code. In our application, we can use &lt;/p&gt;
&lt;pre style="color:#000020;background:#f6f8ff;"&gt;context&lt;span style="color:#308080;"&gt;.&lt;/span&gt;Database&lt;span style="color:#308080;"&gt;.&lt;/span&gt;ExecuteSqlCommand&lt;span style="color:#308080;"&gt;(&lt;/span&gt;&lt;span style="color:#800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#1060b6;"&gt;string of SQL&lt;/span&gt;&lt;span style="color:#800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt;&lt;span style="color:#406080;"&gt;;&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;to execute a SQL instruction against the database. We might consider reading our SQL script into a string, then executing it with ExecuteSqlCommand(), but that won&amp;#39;t work. The problem is that our SQL script is not one SQL command, but many. Each is delimited by the&lt;/p&gt;
&lt;pre style="color:#000020;background:#f6f8ff;"&gt;&lt;span style="font-weight:bold;color:#200080;"&gt;GO&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;instruction. ExecuteSqlCommand will baulk at commands being provided in this way. There are several methods that we can employ to resolve the problem.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Spawn a new process running osql.exe or sqlcmd.exe passing the script file as a parameter&lt;/li&gt;
&lt;li&gt;Use &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/ms162169.aspx" title="SQL Server Management Objects on MSDN"&gt;SQL Server Management Objects&lt;/a&gt; to run the script&lt;/li&gt;
&lt;li&gt;Break the script into commands that can be run using ExecuteSqlCommand()&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I hate spawning out to another process and waiting for it to complete. This isn&amp;#39;t Unix and running up processes is an expensive and time-consuming operation. It&amp;#39;s also, shall we say, a little &amp;#39;inelegant&amp;#39;.&lt;/p&gt;
&lt;p&gt;Ordinarily, I&amp;#39;d use SQL Server Management Objects to run a script. However, in this case, I didn&amp;#39;t want to add further dependencies to the application but rather wanted to keep it lighter weight. So in this case, I chose the third option and wrote a routine that would chop up my SQL script into individual statements and execute them one-by-one.&lt;/p&gt;
&lt;p&gt;Here it is, in its entirety:&lt;/p&gt;
&lt;pre style="color:#000020;background:#f6f8ff;"&gt;&lt;span style="font-weight:bold;color:#200080;"&gt;private&lt;/span&gt; &lt;span style="font-weight:bold;color:#200080;"&gt;void&lt;/span&gt; RunSQLScript&lt;span style="color:#308080;"&gt;(&lt;/span&gt;DbContext context&lt;span style="color:#308080;"&gt;,&lt;/span&gt; &lt;span style="font-weight:bold;color:#200080;"&gt;string&lt;/span&gt; scriptFile&lt;span style="color:#308080;"&gt;)&lt;/span&gt;
&lt;span style="color:#406080;"&gt;{&lt;/span&gt;
    var reader &lt;span style="color:#308080;"&gt;=&lt;/span&gt; File&lt;span style="color:#308080;"&gt;.&lt;/span&gt;OpenText&lt;span style="color:#308080;"&gt;(&lt;/span&gt;scriptFile&lt;span style="color:#308080;"&gt;)&lt;/span&gt;&lt;span style="color:#406080;"&gt;;&lt;/span&gt;

    StringBuilder commandBuilder &lt;span style="color:#308080;"&gt;=&lt;/span&gt; &lt;span style="font-weight:bold;color:#200080;"&gt;new&lt;/span&gt; StringBuilder&lt;span style="color:#308080;"&gt;(&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt;&lt;span style="color:#406080;"&gt;;&lt;/span&gt;
    &lt;span style="font-weight:bold;color:#200080;"&gt;string&lt;/span&gt; line&lt;span style="color:#406080;"&gt;;&lt;/span&gt;

    &lt;span style="font-weight:bold;color:#200080;"&gt;while&lt;/span&gt; &lt;span style="color:#308080;"&gt;(&lt;/span&gt;&lt;span style="color:#308080;"&gt;!&lt;/span&gt;reader&lt;span style="color:#308080;"&gt;.&lt;/span&gt;EndOfStream&lt;span style="color:#308080;"&gt;)&lt;/span&gt;
    &lt;span style="color:#406080;"&gt;{&lt;/span&gt;
        line &lt;span style="color:#308080;"&gt;=&lt;/span&gt; reader&lt;span style="color:#308080;"&gt;.&lt;/span&gt;ReadLine&lt;span style="color:#308080;"&gt;(&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt;&lt;span style="color:#406080;"&gt;;&lt;/span&gt;

        &lt;span style="font-weight:bold;color:#200080;"&gt;if&lt;/span&gt; &lt;span style="color:#308080;"&gt;(&lt;/span&gt;line&lt;span style="color:#308080;"&gt;.&lt;/span&gt;Trim&lt;span style="color:#308080;"&gt;(&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt;&lt;span style="color:#308080;"&gt;.&lt;/span&gt;ToLower&lt;span style="color:#308080;"&gt;(&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt; &lt;span style="color:#308080;"&gt;=&lt;/span&gt;&lt;span style="color:#308080;"&gt;=&lt;/span&gt; &lt;span style="color:#800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#1060b6;"&gt;go&lt;/span&gt;&lt;span style="color:#800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt;
        &lt;span style="color:#406080;"&gt;{&lt;/span&gt;
            context&lt;span style="color:#308080;"&gt;.&lt;/span&gt;Database&lt;span style="color:#308080;"&gt;.&lt;/span&gt;ExecuteSqlCommand&lt;span style="color:#308080;"&gt;(&lt;/span&gt;commandBuilder&lt;span style="color:#308080;"&gt;.&lt;/span&gt;ToString&lt;span style="color:#308080;"&gt;(&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt;&lt;span style="color:#406080;"&gt;;&lt;/span&gt;
            commandBuilder&lt;span style="color:#308080;"&gt;.&lt;/span&gt;Clear&lt;span style="color:#308080;"&gt;(&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt;&lt;span style="color:#406080;"&gt;;&lt;/span&gt;
        &lt;span style="color:#406080;"&gt;}&lt;/span&gt;
        &lt;span style="font-weight:bold;color:#200080;"&gt;else&lt;/span&gt;
        &lt;span style="color:#406080;"&gt;{&lt;/span&gt;
            commandBuilder&lt;span style="color:#308080;"&gt;.&lt;/span&gt;Append&lt;span style="color:#308080;"&gt;(&lt;/span&gt;line&lt;span style="color:#308080;"&gt;)&lt;/span&gt;&lt;span style="color:#406080;"&gt;;&lt;/span&gt;
            commandBuilder&lt;span style="color:#308080;"&gt;.&lt;/span&gt;Append&lt;span style="color:#308080;"&gt;(&lt;/span&gt;&lt;span style="color:#800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#1060b6;"&gt;\r\n&lt;/span&gt;&lt;span style="color:#800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt;&lt;span style="color:#406080;"&gt;;&lt;/span&gt;
        &lt;span style="color:#406080;"&gt;}&lt;/span&gt;
    &lt;span style="color:#406080;"&gt;}&lt;/span&gt;

    &lt;span style="font-weight:bold;color:#200080;"&gt;if&lt;/span&gt; &lt;span style="color:#308080;"&gt;(&lt;/span&gt;commandBuilder&lt;span style="color:#308080;"&gt;.&lt;/span&gt;Length &lt;span style="color:#308080;"&gt;&amp;gt;&lt;/span&gt; &lt;span style="color:#008c00;"&gt;0&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt;
    &lt;span style="color:#406080;"&gt;{&lt;/span&gt;
        context&lt;span style="color:#308080;"&gt;.&lt;/span&gt;Database&lt;span style="color:#308080;"&gt;.&lt;/span&gt;ExecuteSqlCommand&lt;span style="color:#308080;"&gt;(&lt;/span&gt;commandBuilder&lt;span style="color:#308080;"&gt;.&lt;/span&gt;ToString&lt;span style="color:#308080;"&gt;(&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt;&lt;span style="color:#406080;"&gt;;&lt;/span&gt;
    &lt;span style="color:#406080;"&gt;}&lt;/span&gt;
&lt;span style="color:#406080;"&gt;}&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;The method assumes that statements are delimited by a &amp;quot;GO&amp;quot; instruction on a line by itself. It builds up the SQL command in a StringBuilder and executes it when it encounters a &amp;quot;GO&amp;quot;. The extra call to ExecuteSqlCommand() at the end is there to cater for scripts that don&amp;#39;t have a &amp;quot;GO&amp;quot; as the last instruction. As a refinement, I should really get the code to skip blank lines (and maybe comments).&lt;/p&gt;
&lt;p&gt;Armed with my new ability to run a SQL script, I updated the Seed() method as follows:&lt;/p&gt;
&lt;pre style="color:#000020;background:#f6f8ff;"&gt;&lt;span style="font-weight:bold;color:#200080;"&gt;protected&lt;/span&gt; &lt;span style="font-weight:bold;color:#200080;"&gt;override&lt;/span&gt; &lt;span style="font-weight:bold;color:#200080;"&gt;void&lt;/span&gt; Seed&lt;span style="color:#308080;"&gt;(&lt;/span&gt;SchoolContext context&lt;span style="color:#308080;"&gt;)&lt;/span&gt;
&lt;span style="color:#406080;"&gt;{&lt;/span&gt;
    var students &lt;span style="color:#308080;"&gt;=&lt;/span&gt; &lt;span style="font-weight:bold;color:#200080;"&gt;new&lt;/span&gt; List&lt;span style="color:#308080;"&gt;&amp;lt;&lt;/span&gt;Student&lt;span style="color:#308080;"&gt;&amp;gt;&lt;/span&gt;
    &lt;span style="color:#406080;"&gt;{&lt;/span&gt;
        &lt;span style="font-weight:bold;color:#200080;"&gt;new&lt;/span&gt; Student &lt;span style="color:#406080;"&gt;{&lt;/span&gt; FirstMidName &lt;span style="color:#308080;"&gt;=&lt;/span&gt; &lt;span style="color:#800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#1060b6;"&gt;Carson&lt;/span&gt;&lt;span style="color:#800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#308080;"&gt;,&lt;/span&gt;   LastName &lt;span style="color:#308080;"&gt;=&lt;/span&gt; &lt;span style="color:#800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#1060b6;"&gt;Alexander&lt;/span&gt;&lt;span style="color:#800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#308080;"&gt;,&lt;/span&gt; EnrollmentDate &lt;span style="color:#308080;"&gt;=&lt;/span&gt; DateTime&lt;span style="color:#308080;"&gt;.&lt;/span&gt;Parse&lt;span style="color:#308080;"&gt;(&lt;/span&gt;&lt;span style="color:#800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#1060b6;"&gt;2005-09-01&lt;/span&gt;&lt;span style="color:#800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt; &lt;span style="color:#406080;"&gt;}&lt;/span&gt;&lt;span style="color:#308080;"&gt;,&lt;/span&gt;
        &lt;span style="font-weight:bold;color:#200080;"&gt;new&lt;/span&gt; Student &lt;span style="color:#406080;"&gt;{&lt;/span&gt; FirstMidName &lt;span style="color:#308080;"&gt;=&lt;/span&gt; &lt;span style="color:#800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#1060b6;"&gt;Meredith&lt;/span&gt;&lt;span style="color:#800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#308080;"&gt;,&lt;/span&gt; LastName &lt;span style="color:#308080;"&gt;=&lt;/span&gt; &lt;span style="color:#800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#1060b6;"&gt;Alonso&lt;/span&gt;&lt;span style="color:#800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#308080;"&gt;,&lt;/span&gt;    EnrollmentDate &lt;span style="color:#308080;"&gt;=&lt;/span&gt; DateTime&lt;span style="color:#308080;"&gt;.&lt;/span&gt;Parse&lt;span style="color:#308080;"&gt;(&lt;/span&gt;&lt;span style="color:#800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#1060b6;"&gt;2002-09-01&lt;/span&gt;&lt;span style="color:#800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt; &lt;span style="color:#406080;"&gt;}&lt;/span&gt;
    &lt;span style="color:#406080;"&gt;}&lt;/span&gt;&lt;span style="color:#406080;"&gt;;&lt;/span&gt;
    students&lt;span style="color:#308080;"&gt;.&lt;/span&gt;ForEach&lt;span style="color:#308080;"&gt;(&lt;/span&gt;s &lt;span style="color:#308080;"&gt;=&lt;/span&gt;&lt;span style="color:#308080;"&gt;&amp;gt;&lt;/span&gt; context&lt;span style="color:#308080;"&gt;.&lt;/span&gt;Students&lt;span style="color:#308080;"&gt;.&lt;/span&gt;Add&lt;span style="color:#308080;"&gt;(&lt;/span&gt;s&lt;span style="color:#308080;"&gt;)&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt;&lt;span style="color:#406080;"&gt;;&lt;/span&gt;
    context&lt;span style="color:#308080;"&gt;.&lt;/span&gt;SaveChanges&lt;span style="color:#308080;"&gt;(&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt;&lt;span style="color:#406080;"&gt;;&lt;/span&gt;

    &lt;span style="color:#595979;"&gt;// Code yet again removed for brevity&lt;/span&gt;

    RunSQLScript&lt;span style="color:#308080;"&gt;(&lt;/span&gt;context&lt;span style="color:#308080;"&gt;,&lt;/span&gt; @&lt;span style="color:#800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#1060b6;"&gt;C:\ContosoUniversity\ContosoUniversity\ContosoUniversity\DBScripts\InstallSqlStateProcs.SQL&lt;/span&gt;&lt;span style="color:#800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt;&lt;span style="color:#406080;"&gt;;&lt;/span&gt;
&lt;span style="color:#406080;"&gt;}&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;I was feeling somewhat lazy by this point, so specified the full path to the SQL script. In reality, this should be picked up from the relevant location.&lt;/p&gt;
&lt;p&gt;That takes care of getting EF to set my database up to support the ASP.NET SQL Server Session State Provider. All that remains is to configure the application to use SQL Server Session State:&lt;/p&gt;
&lt;pre style="color:#000020;background:#f6f8ff;"&gt;&lt;span style="color:#0057a6;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#333385;"&gt;system.web&lt;/span&gt;&lt;span style="color:#0057a6;"&gt;&amp;gt;&lt;/span&gt;
    &lt;span style="color:#0057a6;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#333385;"&gt;sessionState&lt;/span&gt; &lt;span style="color:#474796;"&gt;mode&lt;/span&gt;&lt;span style="color:#308080;"&gt;=&lt;/span&gt;&lt;span style="color:#1060b6;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#1060b6;"&gt;SQLServer&lt;/span&gt;&lt;span style="color:#1060b6;"&gt;&amp;quot;&lt;/span&gt; &lt;span style="color:#474796;"&gt;sqlConnectionString&lt;/span&gt;&lt;span style="color:#308080;"&gt;=&lt;/span&gt;&lt;span style="color:#1060b6;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#1060b6;"&gt;Data Source=.\SQLExpress;Initial Catalog=School;Integrated Security=SSPI&lt;/span&gt;&lt;span style="color:#1060b6;"&gt;&amp;quot;&lt;/span&gt; &lt;span style="color:#474796;"&gt;cookieless&lt;/span&gt;&lt;span style="color:#308080;"&gt;=&lt;/span&gt;&lt;span style="color:#1060b6;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#1060b6;"&gt;false&lt;/span&gt;&lt;span style="color:#1060b6;"&gt;&amp;quot;&lt;/span&gt; &lt;span style="color:#474796;"&gt;timeout&lt;/span&gt;&lt;span style="color:#308080;"&gt;=&lt;/span&gt;&lt;span style="color:#1060b6;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#1060b6;"&gt;20&lt;/span&gt;&lt;span style="color:#1060b6;"&gt;&amp;quot;&lt;/span&gt; &lt;span style="color:#474796;"&gt;allowCustomSqlDatabase&lt;/span&gt;&lt;span style="color:#308080;"&gt;=&lt;/span&gt;&lt;span style="color:#1060b6;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#1060b6;"&gt;true&lt;/span&gt;&lt;span style="color:#1060b6;"&gt;&amp;quot;&lt;/span&gt; &lt;span style="color:#0057a6;"&gt;/&amp;gt;&lt;/span&gt;
&lt;span style="color:#0057a6;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#333385;"&gt;system.web&lt;/span&gt;&lt;span style="color:#0057a6;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;The sample Contoso University application doesn&amp;#39;t use Session State at all, so to test, I added a couple of lines of code to the CoursesController...&lt;/p&gt;
&lt;pre style="color:#000020;background:#f6f8ff;"&gt;&lt;span style="font-weight:bold;color:#200080;"&gt;public&lt;/span&gt; ActionResult Create&lt;span style="color:#308080;"&gt;(&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt;
&lt;span style="color:#406080;"&gt;{&lt;/span&gt;
    Session&lt;span style="color:#308080;"&gt;[&lt;/span&gt;&lt;span style="color:#800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#1060b6;"&gt;SomethingInSession&lt;/span&gt;&lt;span style="color:#800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#308080;"&gt;]&lt;/span&gt; &lt;span style="color:#308080;"&gt;=&lt;/span&gt; &lt;span style="color:#800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#1060b6;"&gt;Hello!&lt;/span&gt;&lt;span style="color:#800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#406080;"&gt;;&lt;/span&gt;
    PopulateDepartmentsDropDownList&lt;span style="color:#308080;"&gt;(&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt;&lt;span style="color:#406080;"&gt;;&lt;/span&gt;
    &lt;span style="font-weight:bold;color:#200080;"&gt;return&lt;/span&gt; View&lt;span style="color:#308080;"&gt;(&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt;&lt;span style="color:#406080;"&gt;;&lt;/span&gt;
&lt;span style="color:#406080;"&gt;}&lt;/span&gt;

&lt;span style="color:#308080;"&gt;[&lt;/span&gt;HttpPost&lt;span style="color:#308080;"&gt;]&lt;/span&gt;
&lt;span style="font-weight:bold;color:#200080;"&gt;public&lt;/span&gt; ActionResult Create&lt;span style="color:#308080;"&gt;(&lt;/span&gt;Course course&lt;span style="color:#308080;"&gt;)&lt;/span&gt;
&lt;span style="color:#406080;"&gt;{&lt;/span&gt;
    System&lt;span style="color:#308080;"&gt;.&lt;/span&gt;Diagnostics&lt;span style="color:#308080;"&gt;.&lt;/span&gt;Debug&lt;span style="color:#308080;"&gt;.&lt;/span&gt;Assert&lt;span style="color:#308080;"&gt;(&lt;/span&gt;Session&lt;span style="color:#308080;"&gt;[&lt;/span&gt;&lt;span style="color:#800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#1060b6;"&gt;SomethingInSession&lt;/span&gt;&lt;span style="color:#800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#308080;"&gt;]&lt;/span&gt; &lt;span style="color:#308080;"&gt;=&lt;/span&gt;&lt;span style="color:#308080;"&gt;=&lt;/span&gt; &lt;span style="color:#800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#1060b6;"&gt;Hello!&lt;/span&gt;&lt;span style="color:#800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt;&lt;span style="color:#406080;"&gt;;&lt;/span&gt;

    &lt;span style="color:#595979;"&gt;// Snip&lt;/span&gt;
&lt;span style="color:#406080;"&gt;}&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;So, that&amp;#39;s it. I won&amp;#39;t be surprised to find further issues as we move through the lifecycle, but this seems like a good start. I hope you find it of use, too.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://hastobe.net/aggbug.aspx?PostID=509" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=mpfCRjztXjU:XXmL8BBkQOQ:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=mpfCRjztXjU:XXmL8BBkQOQ:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?i=mpfCRjztXjU:XXmL8BBkQOQ:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=mpfCRjztXjU:XXmL8BBkQOQ:l6gmwiTKsz0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?d=l6gmwiTKsz0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=mpfCRjztXjU:XXmL8BBkQOQ:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=mpfCRjztXjU:XXmL8BBkQOQ:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?i=mpfCRjztXjU:XXmL8BBkQOQ:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=mpfCRjztXjU:XXmL8BBkQOQ:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?i=mpfCRjztXjU:XXmL8BBkQOQ:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/hastobedotnet/~4/mpfCRjztXjU" height="1" width="1"/&gt;</description><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Azure/default.aspx">Azure</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Windows+Azure/default.aspx">Windows Azure</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Code-First/default.aspx">Code-First</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/SQL+Azure/default.aspx">SQL Azure</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/EF/default.aspx">EF</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Entity+Framework/default.aspx">Entity Framework</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Session+State/default.aspx">Session State</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/SQL+Server/default.aspx">SQL Server</category><feedburner:origLink>http://hastobe.net/blogs/stevemorgan/archive/2011/08/12/howto-use-asp-net-sql-server-session-state-provider-with-entity-framework-code-first-with-sql-azure-part-ii.aspx</feedburner:origLink></item><item><title>Howto: Use ASP.NET SQL Server Session State Provider with Entity Framework Code-First with SQL Azure - Part I</title><link>http://feedproxy.google.com/~r/hastobedotnet/~3/LNOu7bxNvm4/howto-use-asp-net-sql-server-session-state-provider-with-entity-framework-code-first-with-sql-azure.aspx</link><pubDate>Thu, 11 Aug 2011 21:52:00 GMT</pubDate><guid isPermaLink="false">b3b1d9c2-f4c9-4970-bb5d-c90d4bed0aec:508</guid><dc:creator>Steve Morgan</dc:creator><slash:comments>1</slash:comments><wfw:commentRss>http://hastobe.net/blogs/stevemorgan/rsscomments.aspx?PostID=508</wfw:commentRss><comments>http://hastobe.net/blogs/stevemorgan/archive/2011/08/11/howto-use-asp-net-sql-server-session-state-provider-with-entity-framework-code-first-with-sql-azure.aspx#comments</comments><description>&lt;p&gt;This article was prompted in response to a question on my favourite programmers&amp;#39; site, &lt;a target="_blank" href="http://stackoverflow.com/questions/7015309/can-i-store-session-state-in-my-asp-net-mvc-apps-existing-sql-azure-db/7015870#7015870" title="Original question on StackOverflow.com"&gt;StackOverflow.com&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;As part of&amp;nbsp;my work on an&amp;nbsp;accelerated engineering process for Windows Azure applications, I&amp;#39;ve been implementing SQL Server (and SQL Azure) databases using a database-first approach. However, it&amp;#39;s hoped that moving to EF Code-First can further improve the engineering process and the latest code generators that my team and I are working with implement business databases this way.&lt;/p&gt;
&lt;p&gt;Another design issue to deal with is that of session state. While there are Azure providers that use Azure Table Storage, I&amp;#39;ve had more success with the standard SQL Server Session State Provider, as I&amp;#39;ve found the Table Storage Provider to be somewhat unreliable in the development fabric.&lt;/p&gt;
&lt;p&gt;There&amp;#39;s an argument that using Table Storage for session state is more cost-effective that using SQL Server Session State with Windows Azure, as you have to pay for SQL Azure databases. That argument is weakened somewhat if you&amp;#39;re using SQL Azure, anyway, but it still holds true if you have to pay for a separate SQL Azure database, just to hold the state.&lt;/p&gt;
&lt;p&gt;The ideal, then, in my case, is to use the main application SQL Azure database for both business data and session state.&lt;/p&gt;
&lt;p&gt;Using our previous code generators, with a database-first implementation, that was straightforward enough. Setting up the database for session state involves simply running a SQL script. The standard InstallSqlState.SQL script doesn&amp;#39;t work, as it fails against some of the limitations of SQL Azure. I found a modified script, over at &lt;a target="_blank" href="http://social.msdn.microsoft.com/Forums/en-US/windowsazuredata/thread/cd2f0b6f-31b8-4982-ad32-79cae92211af/" title="Modified InstallSqlState.SQL script at MSDN Forums"&gt;MSDN Forums&lt;/a&gt;. That was a good starting point, but it needs some modifications. Not least, I removed references to the&amp;nbsp;[AspState] database and the creation of users. You can download a copy of my modified script &lt;a href="http://hastobe.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/stevemorgan/InstallSqlState.SQL" title="Modified ASP.NET SQL Server State SQL script"&gt;here&lt;/a&gt;. It turns out that more changes would be required, but more later.&lt;/p&gt;
&lt;p&gt;The problem is that if you simply run this script against your EF Code-First database, it will be lost if EF subsequently regenerates the database. And it turns out, it&amp;#39;s not happy if the database contains tables that it doesn&amp;#39;t know about.&lt;/p&gt;
&lt;p&gt;The trick, then, is to have EF manage the tables along with those required to contain the business data.&lt;/p&gt;
&lt;p&gt;Because I didn&amp;#39;t want to risk breaking an existing application, I headed over to MSDN, downloaded the &lt;a target="_blank" href="http://code.msdn.microsoft.com/ASPNET-MVC-Application-b01a9fe8/sourcecode?fileId=25232&amp;amp;pathId=138753703" title="Sample application code"&gt;Contoso University ASP.NET MVC Application Using Entity Framework Code First&lt;/a&gt;&amp;nbsp;sample and used this as the basis for my investigations.&lt;/p&gt;
&lt;p&gt;I created a new database under SQL Express (it&amp;#39;s easy enough to migrate it to SQL Azure using the &lt;a target="_blank" href="http://sqlazuremw.codeplex.com/" title="SQL Azure Migration Wizard"&gt;SQL Azure Migration Wizard&lt;/a&gt; later). Then, using SQL Server Management Studio, I ran the modified &lt;a href="http://hastobe.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/stevemorgan/InstallSqlState.SQL" title="Download the modified InstallSqlState.SQL script"&gt;InstallSqlState.SQL&lt;/a&gt; to set up the tables for the SQL Server Session State Provider. It creates numerous stored procedures, too, but these ultimately get thrown away.&lt;/p&gt;
&lt;p&gt;Next, I downloaded and installed the &lt;a target="_blank" href="http://visualstudiogallery.msdn.microsoft.com/72a60b14-1581-4b9b-89f2-846072eff19d" title="EF Power Tools"&gt;EF Power Tools CTP&lt;/a&gt;&amp;nbsp;from within Visual Studio 2010 (Tools -&amp;gt; Extension Manager and search the online gallery for Entity Framework&amp;nbsp;Power Tools).&lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://hastobe.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/stevemorgan/extensionmanager.png" title="Click to expand"&gt;&lt;img height="295" width="478" src="http://hastobe.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/stevemorgan/extensionmanager.png" alt="Visual Studio 2010 Extension Manager" style="vertical-align:middle;" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;After restarting Visual Studio, one the installation was complete, my solution was reloaded.&lt;/p&gt;
&lt;p&gt;I right-clicked on the ContosoUniversity project and selected Entity Framework -&amp;gt; Reverse Engineer Code First. &lt;/p&gt;
&lt;p&gt;&lt;img height="166" width="590" src="http://hastobe.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/stevemorgan/reverseengineer.png" alt="Reverse Engineer Code First context menu item" /&gt;&lt;/p&gt;
&lt;p&gt;Then, you simply connect to the new database and let the Power Tool do its stuff:&lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://hastobe.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/stevemorgan/connectdatabase.png" title="Click to expand"&gt;&lt;img height="330" width="225" src="http://hastobe.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/stevemorgan/connectdatabase.png" alt="Connecting to the empty database" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The import process creates a new context class (called SchoolContext.cs in my case, because the database was called School), an Entities folder with classes for the ASP State tables and a Mapping folder containing mapping classes). It also adds a connection string for the database to web.config.&lt;/p&gt;
&lt;p&gt;I then set to work pulling the wizard&amp;#39;s work apart an integrating into the application. First step was to add the new tables to the SchoolContext class. Because the wizard generates its context class in the root of the project, it was simple enough to copy-and-paste between the two before deleting the generated class.&lt;/p&gt;
&lt;pre style="color:#000020;background:#f6f8ff;"&gt;&lt;span style="color:#200080;font-weight:bold;"&gt;     public&lt;/span&gt; &lt;span style="color:#200080;font-weight:bold;"&gt;class&lt;/span&gt; SchoolContext &lt;span style="color:#308080;"&gt;:&lt;/span&gt; DbContext
    &lt;span style="color:#406080;"&gt;{&lt;/span&gt;
        &lt;span style="color:#200080;font-weight:bold;"&gt;public&lt;/span&gt; DbSet&lt;span style="color:#308080;"&gt;&amp;lt;&lt;/span&gt;ASPStateTempApplication&lt;span style="color:#308080;"&gt;&amp;gt;&lt;/span&gt; ASPStateTempApplications &lt;span style="color:#406080;"&gt;{&lt;/span&gt; get&lt;span style="color:#406080;"&gt;;&lt;/span&gt; set&lt;span style="color:#406080;"&gt;;&lt;/span&gt; &lt;span style="color:#406080;"&gt;}&lt;/span&gt;
        &lt;span style="color:#200080;font-weight:bold;"&gt;public&lt;/span&gt; DbSet&lt;span style="color:#308080;"&gt;&amp;lt;&lt;/span&gt;ASPStateTempSession&lt;span style="color:#308080;"&gt;&amp;gt;&lt;/span&gt; ASPStateTempSessions &lt;span style="color:#406080;"&gt;{&lt;/span&gt; get&lt;span style="color:#406080;"&gt;;&lt;/span&gt; set&lt;span style="color:#406080;"&gt;;&lt;/span&gt; &lt;span style="color:#406080;"&gt;}&lt;/span&gt;
        &lt;span style="color:#200080;font-weight:bold;"&gt;public&lt;/span&gt; DbSet&lt;span style="color:#308080;"&gt;&amp;lt;&lt;/span&gt;Course&lt;span style="color:#308080;"&gt;&amp;gt;&lt;/span&gt; Courses &lt;span style="color:#406080;"&gt;{&lt;/span&gt; get&lt;span style="color:#406080;"&gt;;&lt;/span&gt; set&lt;span style="color:#406080;"&gt;;&lt;/span&gt; &lt;span style="color:#406080;"&gt;}&lt;/span&gt;
        &lt;span style="color:#200080;font-weight:bold;"&gt;public&lt;/span&gt; DbSet&lt;span style="color:#308080;"&gt;&amp;lt;&lt;/span&gt;Department&lt;span style="color:#308080;"&gt;&amp;gt;&lt;/span&gt; Departments &lt;span style="color:#406080;"&gt;{&lt;/span&gt; get&lt;span style="color:#406080;"&gt;;&lt;/span&gt; set&lt;span style="color:#406080;"&gt;;&lt;/span&gt; &lt;span style="color:#406080;"&gt;}&lt;/span&gt;
        &lt;span style="color:#200080;font-weight:bold;"&gt;public&lt;/span&gt; DbSet&lt;span style="color:#308080;"&gt;&amp;lt;&lt;/span&gt;Enrollment&lt;span style="color:#308080;"&gt;&amp;gt;&lt;/span&gt; Enrollments &lt;span style="color:#406080;"&gt;{&lt;/span&gt; get&lt;span style="color:#406080;"&gt;;&lt;/span&gt; set&lt;span style="color:#406080;"&gt;;&lt;/span&gt; &lt;span style="color:#406080;"&gt;}&lt;/span&gt;
        &lt;span style="color:#200080;font-weight:bold;"&gt;public&lt;/span&gt; DbSet&lt;span style="color:#308080;"&gt;&amp;lt;&lt;/span&gt;Instructor&lt;span style="color:#308080;"&gt;&amp;gt;&lt;/span&gt; Instructors &lt;span style="color:#406080;"&gt;{&lt;/span&gt; get&lt;span style="color:#406080;"&gt;;&lt;/span&gt; set&lt;span style="color:#406080;"&gt;;&lt;/span&gt; &lt;span style="color:#406080;"&gt;}&lt;/span&gt;
        &lt;span style="color:#200080;font-weight:bold;"&gt;public&lt;/span&gt; DbSet&lt;span style="color:#308080;"&gt;&amp;lt;&lt;/span&gt;Student&lt;span style="color:#308080;"&gt;&amp;gt;&lt;/span&gt; Students &lt;span style="color:#406080;"&gt;{&lt;/span&gt; get&lt;span style="color:#406080;"&gt;;&lt;/span&gt; set&lt;span style="color:#406080;"&gt;;&lt;/span&gt; &lt;span style="color:#406080;"&gt;}&lt;/span&gt;
        &lt;span style="color:#200080;font-weight:bold;"&gt;public&lt;/span&gt; DbSet&lt;span style="color:#308080;"&gt;&amp;lt;&lt;/span&gt;Person&lt;span style="color:#308080;"&gt;&amp;gt;&lt;/span&gt; People &lt;span style="color:#406080;"&gt;{&lt;/span&gt; get&lt;span style="color:#406080;"&gt;;&lt;/span&gt; set&lt;span style="color:#406080;"&gt;;&lt;/span&gt; &lt;span style="color:#406080;"&gt;}&lt;/span&gt;
        &lt;span style="color:#200080;font-weight:bold;"&gt;public&lt;/span&gt; DbSet&lt;span style="color:#308080;"&gt;&amp;lt;&lt;/span&gt;OfficeAssignment&lt;span style="color:#308080;"&gt;&amp;gt;&lt;/span&gt; OfficeAssignments &lt;span style="color:#406080;"&gt;{&lt;/span&gt; get&lt;span style="color:#406080;"&gt;;&lt;/span&gt; set&lt;span style="color:#406080;"&gt;;&lt;/span&gt; &lt;span style="color:#406080;"&gt;}&lt;/span&gt;

        &lt;span style="color:#200080;font-weight:bold;"&gt;protected&lt;/span&gt; &lt;span style="color:#200080;font-weight:bold;"&gt;override&lt;/span&gt; &lt;span style="color:#200080;font-weight:bold;"&gt;void&lt;/span&gt; OnModelCreating&lt;span style="color:#308080;"&gt;(&lt;/span&gt;DbModelBuilder modelBuilder&lt;span style="color:#308080;"&gt;)&lt;/span&gt;
        &lt;span style="color:#406080;"&gt;{&lt;/span&gt;
            modelBuilder&lt;span style="color:#308080;"&gt;.&lt;/span&gt;Conventions&lt;span style="color:#308080;"&gt;.&lt;/span&gt;Remove&lt;span style="color:#308080;"&gt;&amp;lt;&lt;/span&gt;PluralizingTableNameConvention&lt;span style="color:#308080;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color:#308080;"&gt;(&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt;&lt;span style="color:#406080;"&gt;;&lt;/span&gt;
            modelBuilder&lt;span style="color:#308080;"&gt;.&lt;/span&gt;Configurations&lt;span style="color:#308080;"&gt;.&lt;/span&gt;Add&lt;span style="color:#308080;"&gt;(&lt;/span&gt;&lt;span style="color:#200080;font-weight:bold;"&gt;new&lt;/span&gt; ASPStateTempApplicationMap&lt;span style="color:#308080;"&gt;(&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt;&lt;span style="color:#406080;"&gt;;&lt;/span&gt;
            modelBuilder&lt;span style="color:#308080;"&gt;.&lt;/span&gt;Configurations&lt;span style="color:#308080;"&gt;.&lt;/span&gt;Add&lt;span style="color:#308080;"&gt;(&lt;/span&gt;&lt;span style="color:#200080;font-weight:bold;"&gt;new&lt;/span&gt; ASPStateTempSessionMap&lt;span style="color:#308080;"&gt;(&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt;&lt;span style="color:#406080;"&gt;;&lt;/span&gt;
            modelBuilder&lt;span style="color:#308080;"&gt;.&lt;/span&gt;Entity&lt;span style="color:#308080;"&gt;&amp;lt;&lt;/span&gt;Instructor&lt;span style="color:#308080;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color:#308080;"&gt;(&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt;
                &lt;span style="color:#308080;"&gt;.&lt;/span&gt;HasOptional&lt;span style="color:#308080;"&gt;(&lt;/span&gt;p &lt;span style="color:#308080;"&gt;=&lt;/span&gt;&lt;span style="color:#308080;"&gt;&amp;gt;&lt;/span&gt; p&lt;span style="color:#308080;"&gt;.&lt;/span&gt;OfficeAssignment&lt;span style="color:#308080;"&gt;)&lt;/span&gt;&lt;span style="color:#308080;"&gt;.&lt;/span&gt;WithRequired&lt;span style="color:#308080;"&gt;(&lt;/span&gt;p &lt;span style="color:#308080;"&gt;=&lt;/span&gt;&lt;span style="color:#308080;"&gt;&amp;gt;&lt;/span&gt; p&lt;span style="color:#308080;"&gt;.&lt;/span&gt;Instructor&lt;span style="color:#308080;"&gt;)&lt;/span&gt;&lt;span style="color:#406080;"&gt;;&lt;/span&gt;
            modelBuilder&lt;span style="color:#308080;"&gt;.&lt;/span&gt;Entity&lt;span style="color:#308080;"&gt;&amp;lt;&lt;/span&gt;Course&lt;span style="color:#308080;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color:#308080;"&gt;(&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt;
                &lt;span style="color:#308080;"&gt;.&lt;/span&gt;HasMany&lt;span style="color:#308080;"&gt;(&lt;/span&gt;c &lt;span style="color:#308080;"&gt;=&lt;/span&gt;&lt;span style="color:#308080;"&gt;&amp;gt;&lt;/span&gt; c&lt;span style="color:#308080;"&gt;.&lt;/span&gt;Instructors&lt;span style="color:#308080;"&gt;)&lt;/span&gt;&lt;span style="color:#308080;"&gt;.&lt;/span&gt;WithMany&lt;span style="color:#308080;"&gt;(&lt;/span&gt;i &lt;span style="color:#308080;"&gt;=&lt;/span&gt;&lt;span style="color:#308080;"&gt;&amp;gt;&lt;/span&gt; i&lt;span style="color:#308080;"&gt;.&lt;/span&gt;Courses&lt;span style="color:#308080;"&gt;)&lt;/span&gt;
                &lt;span style="color:#308080;"&gt;.&lt;/span&gt;Map&lt;span style="color:#308080;"&gt;(&lt;/span&gt;t &lt;span style="color:#308080;"&gt;=&lt;/span&gt;&lt;span style="color:#308080;"&gt;&amp;gt;&lt;/span&gt; t&lt;span style="color:#308080;"&gt;.&lt;/span&gt;MapLeftKey&lt;span style="color:#308080;"&gt;(&lt;/span&gt;&lt;span style="color:#800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#1060b6;"&gt;CourseID&lt;/span&gt;&lt;span style="color:#800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt;
                    &lt;span style="color:#308080;"&gt;.&lt;/span&gt;MapRightKey&lt;span style="color:#308080;"&gt;(&lt;/span&gt;&lt;span style="color:#800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#1060b6;"&gt;PersonID&lt;/span&gt;&lt;span style="color:#800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt;
                    &lt;span style="color:#308080;"&gt;.&lt;/span&gt;ToTable&lt;span style="color:#308080;"&gt;(&lt;/span&gt;&lt;span style="color:#800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#1060b6;"&gt;CourseInstructor&lt;/span&gt;&lt;span style="color:#800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt;&lt;span style="color:#406080;"&gt;;&lt;/span&gt;
            modelBuilder&lt;span style="color:#308080;"&gt;.&lt;/span&gt;Entity&lt;span style="color:#308080;"&gt;&amp;lt;&lt;/span&gt;Department&lt;span style="color:#308080;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color:#308080;"&gt;(&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt;
                &lt;span style="color:#308080;"&gt;.&lt;/span&gt;HasOptional&lt;span style="color:#308080;"&gt;(&lt;/span&gt;x &lt;span style="color:#308080;"&gt;=&lt;/span&gt;&lt;span style="color:#308080;"&gt;&amp;gt;&lt;/span&gt; x&lt;span style="color:#308080;"&gt;.&lt;/span&gt;Administrator&lt;span style="color:#308080;"&gt;)&lt;/span&gt;&lt;span style="color:#406080;"&gt;;&lt;/span&gt;
        &lt;span style="color:#406080;"&gt;}&lt;/span&gt;
    &lt;span style="color:#406080;"&gt;}&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;Next, some modifications were required to the ASPStateTempSessionMap class, to ensure that the table generated by EF matched that created by the script (as far as we can, at least).&lt;/p&gt;
&lt;pre style="color:#000020;background:#f6f8ff;"&gt;&lt;span style="color:#200080;font-weight:bold;"&gt;public&lt;/span&gt; &lt;span style="color:#200080;font-weight:bold;"&gt;class&lt;/span&gt; ASPStateTempSessionMap &lt;span style="color:#308080;"&gt;:&lt;/span&gt; EntityTypeConfiguration&lt;span style="color:#308080;"&gt;&amp;lt;&lt;/span&gt;ASPStateTempSession&lt;span style="color:#308080;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="color:#406080;"&gt;{&lt;/span&gt;
    &lt;span style="color:#200080;font-weight:bold;"&gt;public&lt;/span&gt; ASPStateTempSessionMap&lt;span style="color:#308080;"&gt;(&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt;
    &lt;span style="color:#406080;"&gt;{&lt;/span&gt;
        &lt;span style="color:#595979;"&gt;// Original content removed for brevity...&lt;/span&gt;
        &lt;span style="color:#200080;font-weight:bold;"&gt;this&lt;/span&gt;&lt;span style="color:#308080;"&gt;.&lt;/span&gt;Property&lt;span style="color:#308080;"&gt;(&lt;/span&gt;t &lt;span style="color:#308080;"&gt;=&lt;/span&gt;&lt;span style="color:#308080;"&gt;&amp;gt;&lt;/span&gt; t&lt;span style="color:#308080;"&gt;.&lt;/span&gt;SessionItemLong&lt;span style="color:#308080;"&gt;)&lt;/span&gt;&lt;span style="color:#308080;"&gt;.&lt;/span&gt;HasColumnName&lt;span style="color:#308080;"&gt;(&lt;/span&gt;&lt;span style="color:#800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#1060b6;"&gt;SessionItemLong&lt;/span&gt;&lt;span style="color:#800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt;&lt;span style="color:#308080;"&gt;.&lt;/span&gt;HasColumnType&lt;span style="color:#308080;"&gt;(&lt;/span&gt;&lt;span style="color:#800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#1060b6;"&gt;image&lt;/span&gt;&lt;span style="color:#800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#308080;"&gt;)&lt;/span&gt;&lt;span style="color:#406080;"&gt;;&lt;/span&gt;
        &lt;span style="color:#595979;"&gt;// ...&lt;/span&gt;
    &lt;span style="color:#406080;"&gt;}&lt;/span&gt;
&lt;span style="color:#406080;"&gt;}&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;Here, I&amp;#39;ve added .HasColumnType(&amp;quot;image&amp;quot;), because by default, EF creates the table with a varbinary column, instead.&lt;/p&gt;
&lt;p&gt;Then, a temporary change to the SchoolInitializer class, to force EF to recreate the database...&lt;/p&gt;
&lt;p&gt;I changed&lt;/p&gt;
&lt;pre style="color:#000020;background:#f6f8ff;"&gt;&lt;span style="color:#200080;font-weight:bold;"&gt;public&lt;/span&gt; &lt;span style="color:#200080;font-weight:bold;"&gt;class&lt;/span&gt; SchoolInitializer &lt;span style="color:#308080;"&gt;:&lt;/span&gt; DropCreateDatabaseIfModelChanges&lt;span style="color:#308080;"&gt;&amp;lt;&lt;/span&gt;SchoolContext&lt;span style="color:#308080;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;to&lt;/p&gt;
&lt;pre style="color:#000020;background:#f6f8ff;"&gt;&lt;span style="color:#200080;font-weight:bold;"&gt;public&lt;/span&gt; &lt;span style="color:#200080;font-weight:bold;"&gt;class&lt;/span&gt; SchoolInitializer &lt;span style="color:#308080;"&gt;:&lt;/span&gt; DropCreateDatabaseAlways&lt;span style="color:#308080;"&gt;&amp;lt;&lt;/span&gt;SchoolContext&lt;span style="color:#308080;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;But once I&amp;#39;ve finished, I&amp;#39;ll revert that change.&lt;/p&gt;
&lt;p&gt;Running the application now causes EF to create the database afresh, including the requisite ASPStateTempSessions and ASPStateTempApplications tables. But before&amp;nbsp;I could&amp;nbsp;use the SQL Server Session State Provider, I had to address the problem of the numerous missing stored procedures.&lt;/p&gt;
&lt;p&gt;I address that issue in &lt;a href="http://hastobe.net/blogs/stevemorgan/archive/2011/08/12/howto-use-asp-net-sql-server-session-state-provider-with-entity-framework-code-first-with-sql-azure-part-ii.aspx" title="Part II"&gt;Part II&lt;/a&gt; of this article.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://hastobe.net/aggbug.aspx?PostID=508" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=LNOu7bxNvm4:aZdaNfiRXn0:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=LNOu7bxNvm4:aZdaNfiRXn0:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?i=LNOu7bxNvm4:aZdaNfiRXn0:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=LNOu7bxNvm4:aZdaNfiRXn0:l6gmwiTKsz0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?d=l6gmwiTKsz0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=LNOu7bxNvm4:aZdaNfiRXn0:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=LNOu7bxNvm4:aZdaNfiRXn0:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?i=LNOu7bxNvm4:aZdaNfiRXn0:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=LNOu7bxNvm4:aZdaNfiRXn0:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?i=LNOu7bxNvm4:aZdaNfiRXn0:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/hastobedotnet/~4/LNOu7bxNvm4" height="1" width="1"/&gt;</description><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Azure/default.aspx">Azure</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Windows+Azure/default.aspx">Windows Azure</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Code-First/default.aspx">Code-First</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/SQL+Azure/default.aspx">SQL Azure</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/EF/default.aspx">EF</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Entity+Framework/default.aspx">Entity Framework</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Session+State/default.aspx">Session State</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/SQL+Server/default.aspx">SQL Server</category><feedburner:origLink>http://hastobe.net/blogs/stevemorgan/archive/2011/08/11/howto-use-asp-net-sql-server-session-state-provider-with-entity-framework-code-first-with-sql-azure.aspx</feedburner:origLink></item><item><title>Did DisplayPad crash my Mac OS X Lion upgrade?</title><link>http://feedproxy.google.com/~r/hastobedotnet/~3/z_lQimYQnsA/did-displaypad-crash-my-mac-os-x-lion-upgrade.aspx</link><pubDate>Thu, 21 Jul 2011 15:12:00 GMT</pubDate><guid isPermaLink="false">b3b1d9c2-f4c9-4970-bb5d-c90d4bed0aec:496</guid><dc:creator>Steve Morgan</dc:creator><slash:comments>5</slash:comments><wfw:commentRss>http://hastobe.net/blogs/stevemorgan/rsscomments.aspx?PostID=496</wfw:commentRss><comments>http://hastobe.net/blogs/stevemorgan/archive/2011/07/21/did-displaypad-crash-my-mac-os-x-lion-upgrade.aspx#comments</comments><description>&lt;p&gt;Well, those were a good few hours of my life that I&amp;#39;m not going to get back!&lt;/p&gt;
&lt;p&gt;Like, I suspect, many others, I downloaded Apple&amp;#39;s OS X 10.7 Lion upgrade for my MacBook Pro from the App Store yesterday. To hell with my download allowance, I thought; I&amp;#39;ll just not watch YouTube for the rest of the month.&lt;/p&gt;
&lt;p&gt;The installation went smoothly enough. It did, however, identify one piece of incompatible software, DisplayPad, which it dutifully moved to the Incompatible Software folder at the root of my hard disk.&lt;/p&gt;
&lt;p&gt;A quick search on my Search Engine of Choice revealed an updated version of DisplayPad, 1.0.2, which claims to be compatible with Lion. So I downloaded this latest version and installed it. Given the nature of DisplayPad, I expected it to install some kind of display driver or OS extension to allow the UI that would be tagetted at a second monitor to be relayed to the iPad. This, the installer did and on succesful completion told me that a restart was required.&lt;/p&gt;
&lt;p&gt;I restarted the machine.&lt;/p&gt;
&lt;p&gt;At the initial Apple Logo screen, the progress spinner sat for a while before moving on. The next screen that I saw was the &amp;#39;fabric-look&amp;#39; background to the Lion logon screen. And this is where it all went wrong. Despite waiting for many minutes, the login icons never appeared (I should make it clear at this point that I&amp;#39;ve disabled automatic login for security reasons). My MacBook Pro had crashed!&lt;/p&gt;
&lt;p&gt;After a while, I powered off the machine, restarted and confirmed that the behaviour remained.&lt;/p&gt;
&lt;p&gt;I powered off again and this time, restarted into Safe Mode by holding the Shift key down. I was able to login successfully and did a bit of poking around, but couldn&amp;#39;t see anything obvious. I also wasn&amp;#39;t sure how to uninstall DisplayPad. Dragging it to the Trash Bin doesn&amp;#39;t seem sufficient; no surprise, given that it&amp;#39;s installing that display driver. Again, my Search Engine of Choice yielded no suggestions and the FAQ on the Clean Cut Code site (the producers of DisplayPad) contained only two, less that useful, questions and answers.&lt;/p&gt;
&lt;p&gt;After an hour or so of trying, I gave up and this time restarted using Command-R to bring up the recovery tools.&lt;/p&gt;
&lt;p&gt;Fortunately, my MacBook Pro is regularly backed up to an external hard disk that is attached to my Airport Extreme (my current Wireless Access Point of choice) using Time Machine. The Recovery Tools give you the option of restoring from a Time Machine backup and so I selected the last Snow Leopard backup taken shortly before I upgraded to Lion.&lt;/p&gt;
&lt;p&gt;What followed was a restore lasting around 13 hours. I should consider myself lucky; the original estimate was 21 hours!&lt;/p&gt;
&lt;p&gt;Once the restore was complete, I rebooted and started again. Microsoft Office wanted to rebuild its internal identity store (it warned me that this usually happens when you restore from Time Machine). I was also disappointed to find that Fingerprint, software to support AirPrint with non-AirPrint compatible printers, had reverted to Trial mode and I can&amp;#39;t find my license key. That&amp;#39;s a separate issue, though, and not of concern here.&lt;/p&gt;
&lt;p&gt;So guess what I did? I let DisplayPad update again. Like a fool!&lt;/p&gt;
&lt;p&gt;When I rebooted, I had exactly the same symptoms. The machine got as far as the login screen, but displayed no icons, no prompts, nothing. &lt;/p&gt;
&lt;p&gt;However, in my frustration, I must admit to having a bit of a rattle on the keyboard. Not a vigorous one, obviously, as this is a MacBook Pro and warrants some respect. I was surprised to hear one of those &amp;quot;Don&amp;#39;t press that key again&amp;quot; kind of sounds.&lt;/p&gt;
&lt;p&gt;So, I hit the Enter key and to my further surprise, was logged in to the Guest account (which has no password).&lt;/p&gt;
&lt;p&gt;I logged out and was greeted, again, with a login screen with no icons, no prompts, nothing.&lt;/p&gt;
&lt;p&gt;This time, I pressed the first letter of my username, Enter, my password, Enter. To my relief, I was logged in to my account! Hooray!&lt;/p&gt;
&lt;p&gt;So, it would appear that DisplayPad&amp;#39;s graphics driver is screwing up the Login screen. I could be wrong, but that&amp;#39;s my belief at the moment. I&amp;#39;ve worked around the problem temporarily by turning on Auto-Login again, so the Login screen is never required. And I&amp;#39;ve e-mailed Clean Cut Code for some advice; if not to solve the problem then how to successfully and completely uninstall the application.&lt;/p&gt;
&lt;p&gt;I appreciate that these things happen, but I spent a lot of frustrated hours just getting my machine back to a usable state again. While I await a proper resolution, I&amp;#39;m going back to tame this Lion again...&lt;/p&gt;
&lt;p&gt;UPDATE/FIX:&lt;/p&gt;
&lt;p&gt;Well, I&amp;#39;m pretty convinced that it&amp;#39;s a DisplayPad problem, that&amp;#39;s for sure!&lt;/p&gt;
&lt;p&gt;While mooching around Lion some more, I was finding all kinds of problems. Firefox 5.0.1 wouldn&amp;#39;t display any content in its windows unless I start in Safe Mode. Google Earth didn&amp;#39;t show me the Earth, that sort of thing.&lt;/p&gt;
&lt;p&gt;So, a bit more investigation, and I think I&amp;#39;ve managed to work out how to uninstall DisplayPad.&lt;/p&gt;
&lt;p&gt;Under &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (HDD Root) /System/Library/Extensions&lt;/p&gt;
&lt;p&gt;There are two files:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DisplayPadDriver.kext&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DisplayPadFrameBuffer.kext&lt;/p&gt;
&lt;p&gt;Move these to the Trash to delete them.&lt;/p&gt;
&lt;p&gt;From the &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /Applications&lt;/p&gt;
&lt;p&gt;folder, delete DisplayPad.app by moving it to the Trash bin, too.&lt;/p&gt;
&lt;p&gt;On restart, things seem to be back to normal. Specifically, Firefox is now working without resorting to Safe Mode and Google Earth is going its stuff, too.&lt;/p&gt;
&lt;p&gt;And, YAY! The icons are back in the Logon screen!&lt;/p&gt;
&lt;p&gt;Looks like DisplayPad needs a bit more work before it&amp;#39;s ready for Lion.&lt;/p&gt;
&lt;p&gt;Further Update:&lt;/p&gt;
&lt;p&gt;I heard back from Clean Cut Code about the problem. Apparently, it&amp;#39;s due to a bug in Lion that affects machines with NVidia 9400M graphics cards. My machine is a mid-2009 MacBook Pro and has dual-graphics, an NVidia 9400M for low-power use (typically on battery) and an NVidia 9600M GT which offers higher performance and is generally preferred when connected to the mains. Expect an update from Apple or Clean Cut Code sometime soon that resolves the issue.&lt;/p&gt;
&lt;p&gt;They also advised removing&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /System/Library/Extensions/SSFrameBuffer.kext&lt;/p&gt;
&lt;p&gt;if it exists. It didn&amp;#39;t exist on my machine, but could do on yours.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://hastobe.net/aggbug.aspx?PostID=496" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=z_lQimYQnsA:PnN0BL7X1l4:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=z_lQimYQnsA:PnN0BL7X1l4:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?i=z_lQimYQnsA:PnN0BL7X1l4:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=z_lQimYQnsA:PnN0BL7X1l4:l6gmwiTKsz0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?d=l6gmwiTKsz0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=z_lQimYQnsA:PnN0BL7X1l4:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=z_lQimYQnsA:PnN0BL7X1l4:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?i=z_lQimYQnsA:PnN0BL7X1l4:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=z_lQimYQnsA:PnN0BL7X1l4:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?i=z_lQimYQnsA:PnN0BL7X1l4:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/hastobedotnet/~4/z_lQimYQnsA" height="1" width="1"/&gt;</description><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/OSX/default.aspx">OSX</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Max/default.aspx">Max</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/DisplayPad/default.aspx">DisplayPad</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Lion/default.aspx">Lion</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Hang/default.aspx">Hang</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/OS+X/default.aspx">OS X</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/NVidia/default.aspx">NVidia</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/9400M/default.aspx">9400M</category><feedburner:origLink>http://hastobe.net/blogs/stevemorgan/archive/2011/07/21/did-displaypad-crash-my-mac-os-x-lion-upgrade.aspx</feedburner:origLink></item><item><title>Mac Fix: iTunes was unable to load dataclass information from Sync Services.</title><link>http://feedproxy.google.com/~r/hastobedotnet/~3/29tqVA3lxPA/mac-fix-itunes-was-unable-to-load-dataclass-information-from-sync-services.aspx</link><pubDate>Mon, 14 Mar 2011 14:57:00 GMT</pubDate><guid isPermaLink="false">b3b1d9c2-f4c9-4970-bb5d-c90d4bed0aec:426</guid><dc:creator>Steve Morgan</dc:creator><slash:comments>12</slash:comments><wfw:commentRss>http://hastobe.net/blogs/stevemorgan/rsscomments.aspx?PostID=426</wfw:commentRss><comments>http://hastobe.net/blogs/stevemorgan/archive/2011/03/14/mac-fix-itunes-was-unable-to-load-dataclass-information-from-sync-services.aspx#comments</comments><description>&lt;p&gt;Last week was a fairly big one for the iPhone stack, what with the release of iTunes 10.2.1 and subsequent release of iOS 4.3. Of course, I dutifully installed both. A fairly painless, if long-winded exercise.&lt;/p&gt;
&lt;p&gt;I noticed a couple of days later a problem syncing my phone with my MacBook Pro. On connection of the phone, iTunes displayed the following error message:&lt;/p&gt;
&lt;p&gt;&lt;b&gt;iTunes was unable to load dataclass information from Sync Services. Reconnect or try again later.&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;Well, I did and the same message was displayed next time. So, I rebooted the MacBook Pro and, for good measure, rebooted the iPhone too. On connecting the phone (once iTunes had started up) - no change. Same message.&lt;/p&gt;
&lt;p&gt;On closer inspection, it looked as though the phone was actually syncing but not backing up. Not a situation that I was happy with, so time to start investigating seriously. After much trawling of the usual haunts (starting with my search engine of choice, naturally), I uncovered both the cause and the fix, though the relationship between them isn&amp;#39;t especially obvious. While I supposed that the issue lay with either iTunes 10.2.1 or iOS 4.3, there was another little detail that I hadn&amp;#39;t noticed (and have thus far neglected to mention). Shortly after these upgrades, Apple posted the latest version of XCode to the Mac App Store. Despite not yet having built a real iOS application in anger, I couldn&amp;#39;t not have it, so I clicked the button, entered my Apple password and let XCode install. It was XCode, it appears, that was the root of my synchronisation issues. The connection may seem tenuous, but I suspect it could well be related to the inclusion of the iPhone emulator replacing important files.&lt;/p&gt;
&lt;p&gt;The solution was found on Apple&amp;#39;s support site, here: &lt;a target="_blank" title="iTunes: How to remove and reinstall the Apple Mobile Device Service on Mac OS X" href="http://support.apple.com/kb/HT1747?viewlocale=en_US"&gt;iTunes: How to remove and reinstall the Apple Mobile Device Service on Mac OS X&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Basically, it involves uninstalling iTunes, removing two Apple Mobile Device Service files and reinstalling iTunes. You&amp;#39;ll be especially pleased to know, if you have to go through this process yourself, that all of your iTunes content and configuration remains unharmed.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://hastobe.net/aggbug.aspx?PostID=426" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=29tqVA3lxPA:BcVSuSYXJHw:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=29tqVA3lxPA:BcVSuSYXJHw:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?i=29tqVA3lxPA:BcVSuSYXJHw:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=29tqVA3lxPA:BcVSuSYXJHw:l6gmwiTKsz0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?d=l6gmwiTKsz0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=29tqVA3lxPA:BcVSuSYXJHw:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=29tqVA3lxPA:BcVSuSYXJHw:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?i=29tqVA3lxPA:BcVSuSYXJHw:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=29tqVA3lxPA:BcVSuSYXJHw:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?i=29tqVA3lxPA:BcVSuSYXJHw:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/hastobedotnet/~4/29tqVA3lxPA" height="1" width="1"/&gt;</description><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/iPhone/default.aspx">iPhone</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/iTunes/default.aspx">iTunes</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/OSX/default.aspx">OSX</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Mac/default.aspx">Mac</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Backup/default.aspx">Backup</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Sync/default.aspx">Sync</category><feedburner:origLink>http://hastobe.net/blogs/stevemorgan/archive/2011/03/14/mac-fix-itunes-was-unable-to-load-dataclass-information-from-sync-services.aspx</feedburner:origLink></item><item><title>Printing from iOS 4.2 (iPhone, iPad, iPod Touch) without an AirPrint compatible printer</title><link>http://feedproxy.google.com/~r/hastobedotnet/~3/YQhImMxPcuU/printing-from-ios-4-2-iphone-ipad-ipod-touch-without-an-airprint-compatible-printer.aspx</link><pubDate>Tue, 23 Nov 2010 12:39:00 GMT</pubDate><guid isPermaLink="false">b3b1d9c2-f4c9-4970-bb5d-c90d4bed0aec:385</guid><dc:creator>Steve Morgan</dc:creator><slash:comments>5</slash:comments><wfw:commentRss>http://hastobe.net/blogs/stevemorgan/rsscomments.aspx?PostID=385</wfw:commentRss><comments>http://hastobe.net/blogs/stevemorgan/archive/2010/11/23/printing-from-ios-4-2-iphone-ipad-ipod-touch-without-an-airprint-compatible-printer.aspx#comments</comments><description>&lt;p&gt;Being an iPhone 4 user (I&amp;#39;ve yet to stump up for an iPad), the main feature of iOS4.2 that attracted my attention was the ability to print using AirPrint technology. Of course, HP would love me to go out and buy an AirPrint-compatible printer that the iPhone can talk to. However, I&amp;#39;ve already got three HP printers, a black-and-white Laserjet 3055 all-in-one, a colour Laserjet 2605DN and an A3+ Photosmart B9180 inkjet. HP have had enough money out of me in printers for a while.&lt;/p&gt;
&lt;p&gt;Fortunately, those clever people at &lt;a target="_blank" title="Collobos Software, home of Fingerprint" href="http://www.collobos.com"&gt;Collobos&lt;/a&gt; software have developed a utility for the Mac called Fingerprint. Fingerprint shares your Mac-connected printers as AirPrint devices, so as long as your Mac is on and Fingerprint is running (you can set it to run at startup), any iOS4.2 devices on the same wireless network can print to compatible printers. You have to remember to enable printer sharing in System Preferences, though. Collobos say that not all printers are compatible. I&amp;#39;ve only tested it with the Laserjet 3055 so far but it performed flawlessly printing from Safari and Mail.&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s the FingerPrint application running on my MacBook Pro:&lt;/p&gt;
&lt;p&gt;&lt;img alt="Fingerprint Application" src="http://hastobe.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/stevemorgan/FingerPrintWindow.gif" width="675" height="388" /&gt;&lt;/p&gt;
&lt;p&gt;Back at the iPhone, selecting Print in Safari presents some printing options:&lt;/p&gt;
&lt;p&gt;&lt;img alt="Print Options in Safari" src="http://hastobe.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/stevemorgan/SafariPrinterOptions.gif" width="320" height="480" /&gt;&lt;/p&gt;
&lt;p&gt;Selecting Printer in the print options, you get to choose a printer from the same list that Fingerprint is sharing...&lt;/p&gt;
&lt;p&gt;&lt;img alt="Choosing a printer" src="http://hastobe.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/stevemorgan/AirPrintChoosePrinter.gif" width="320" height="480" /&gt;&lt;/p&gt;
&lt;p&gt;There&amp;#39;s a 7-day trial of Fingerprint available but after having printed the first page, I purchased a full license straight away. It only costs $7.95 (or &amp;pound;6.24 including VAT in the UK) and the purchasing experience is integrated nicely into the app.&lt;/p&gt;
&lt;p&gt;So far, I&amp;#39;ve got nothing but praise for Collobos and their very timely release of Fingerprint. Hopefully, a similar facility will be available for Windows users very soon.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://hastobe.net/aggbug.aspx?PostID=385" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=YQhImMxPcuU:tWH_q0yAM00:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=YQhImMxPcuU:tWH_q0yAM00:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?i=YQhImMxPcuU:tWH_q0yAM00:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=YQhImMxPcuU:tWH_q0yAM00:l6gmwiTKsz0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?d=l6gmwiTKsz0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=YQhImMxPcuU:tWH_q0yAM00:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=YQhImMxPcuU:tWH_q0yAM00:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?i=YQhImMxPcuU:tWH_q0yAM00:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=YQhImMxPcuU:tWH_q0yAM00:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?i=YQhImMxPcuU:tWH_q0yAM00:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/hastobedotnet/~4/YQhImMxPcuU" height="1" width="1"/&gt;</description><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/iPhone/default.aspx">iPhone</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/iPhone4/default.aspx">iPhone4</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/iPhone3GS/default.aspx">iPhone3GS</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/AirPrint/default.aspx">AirPrint</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Fingerprint/default.aspx">Fingerprint</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/iOS4.2/default.aspx">iOS4.2</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/iPad/default.aspx">iPad</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Printing/default.aspx">Printing</category><feedburner:origLink>http://hastobe.net/blogs/stevemorgan/archive/2010/11/23/printing-from-ios-4-2-iphone-ipad-ipod-touch-without-an-airprint-compatible-printer.aspx</feedburner:origLink></item><item><title>Soliciting comments of the Microsoft Azure Developer Portal</title><link>http://feedproxy.google.com/~r/hastobedotnet/~3/ezpgjIkiHCw/soliciting-comments-of-the-microsoft-azure-developer-portal.aspx</link><pubDate>Fri, 15 Oct 2010 12:30:00 GMT</pubDate><guid isPermaLink="false">b3b1d9c2-f4c9-4970-bb5d-c90d4bed0aec:357</guid><dc:creator>Steve Morgan</dc:creator><slash:comments>1</slash:comments><wfw:commentRss>http://hastobe.net/blogs/stevemorgan/rsscomments.aspx?PostID=357</wfw:commentRss><comments>http://hastobe.net/blogs/stevemorgan/archive/2010/10/15/soliciting-comments-of-the-microsoft-azure-developer-portal.aspx#comments</comments><description>&lt;p&gt;I&amp;#39;m interested in what Azure developers think of &lt;a target="_blank" title="Microsoft&amp;#39;s Azure Developer Portal" href="http://windows.azure.com"&gt;Microsoft&amp;#39;s Developer Portal&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;For instance, from an Enterprise delivery perspective, it greatly concerns me that developers can flip-flop Staging and Production with no formal change control.&lt;/p&gt;
&lt;p&gt;What&amp;#39;s your view? If there are things that you think are good or bad, post a comment and once I&amp;#39;ve reviewed it, I&amp;#39;ll try to collate the results here into something meaningful.&lt;/p&gt;
&lt;p&gt;Please note that comments are moderated, so you won&amp;#39;t see anyone else&amp;#39;s contributions until I&amp;#39;ve checked them out.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://hastobe.net/aggbug.aspx?PostID=357" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=ezpgjIkiHCw:JOq271B_aJA:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=ezpgjIkiHCw:JOq271B_aJA:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?i=ezpgjIkiHCw:JOq271B_aJA:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=ezpgjIkiHCw:JOq271B_aJA:l6gmwiTKsz0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?d=l6gmwiTKsz0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=ezpgjIkiHCw:JOq271B_aJA:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=ezpgjIkiHCw:JOq271B_aJA:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?i=ezpgjIkiHCw:JOq271B_aJA:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=ezpgjIkiHCw:JOq271B_aJA:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?i=ezpgjIkiHCw:JOq271B_aJA:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/hastobedotnet/~4/ezpgjIkiHCw" height="1" width="1"/&gt;</description><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Azure/default.aspx">Azure</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Windows+Azure/default.aspx">Windows Azure</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Platform-as-a-Service/default.aspx">Platform-as-a-Service</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/PaaS/default.aspx">PaaS</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Cloud+Computing/default.aspx">Cloud Computing</category><feedburner:origLink>http://hastobe.net/blogs/stevemorgan/archive/2010/10/15/soliciting-comments-of-the-microsoft-azure-developer-portal.aspx</feedburner:origLink></item><item><title>iPhone 4, iOS4.1 and Nokia 616 Bluetooth Compatibility Problems </title><link>http://feedproxy.google.com/~r/hastobedotnet/~3/VvqGBEEIk4Q/iphone-4-ios4-1-and-nokia-616-bluetooth-compatibility-problems.aspx</link><pubDate>Thu, 16 Sep 2010 09:56:00 GMT</pubDate><guid isPermaLink="false">b3b1d9c2-f4c9-4970-bb5d-c90d4bed0aec:337</guid><dc:creator>Steve Morgan</dc:creator><slash:comments>2</slash:comments><wfw:commentRss>http://hastobe.net/blogs/stevemorgan/rsscomments.aspx?PostID=337</wfw:commentRss><comments>http://hastobe.net/blogs/stevemorgan/archive/2010/09/16/iphone-4-ios4-1-and-nokia-616-bluetooth-compatibility-problems.aspx#comments</comments><description>&lt;p&gt;I&amp;#39;ve posted previously about iPhone compatibility with the Nokia 616 Bluetooth car kit and made a few updates along the way. But having regressed in terms of compatibility with the iPhone 4, I thought I&amp;#39;d break out a separate post.&lt;/p&gt;
&lt;p&gt;You&amp;#39;ll find the previous post &lt;a title="iPhone 3g/3gs and Nokia 616 compatibility" href="http://hastobe.net/blogs/stevemorgan/archive/2008/07/29/iphone-3g-works-with-nokia-616-car-kit.aspx"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Today, iTunes offered me the latest iOS version 4.1 for my iPhone 4. Among the release notes I was pleased to see &amp;quot;Bluetooth improvements&amp;quot;. I was keen to see if Apple had addressed the issues that, having been resolved with the iPhone 3g and 3gs, were now plaguing the iPhone 4. So, I let iTunes do its thing and ventured out to the car to check.&lt;/p&gt;
&lt;p&gt;On connecting to the phone, the car kit asked me the question it always asks (because it&amp;#39;s never worked previously): &amp;quot;Download contacts?&amp;quot;. I hit the green button and waited a few seconds. The display on the Nokia 616 displayed &amp;quot;Downloading&amp;quot; and a progress bar. Then, the Bluetooth connection was dropped and the display changed to &amp;quot;Download not supported&amp;quot;. These are the same symptoms that I&amp;#39;ve had since upgrading to the iPhone 4.&lt;/p&gt;
&lt;p&gt;To be on the safe side, I deleted the Bluetooth pairing from both the car kit and the phone, then set them up again from scratch. On attempting to download the contacts, I had exactly the same error.&lt;/p&gt;
&lt;p&gt;The long and the short is that the problem still isn&amp;#39;t fixed. You get prompted to download contacts every time the phone connects and you can only dial by using voice dialling (which works fine over Bluetooth) or using the keypad (which is dangerous on the move). I do wish they&amp;#39;d sort it out. Handsets come and go, but having a car kit fitted is a longer term commitment and having cracked the problem with the iPhone 3g/3gs it&amp;#39;s a real disappointment to see it return with the iPhone 4.&lt;/p&gt;
&lt;p&gt;As ever, I&amp;#39;ll keep you updated if I learn more or until I change the car!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://hastobe.net/aggbug.aspx?PostID=337" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=VvqGBEEIk4Q:ARo8fqewax4:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=VvqGBEEIk4Q:ARo8fqewax4:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?i=VvqGBEEIk4Q:ARo8fqewax4:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=VvqGBEEIk4Q:ARo8fqewax4:l6gmwiTKsz0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?d=l6gmwiTKsz0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=VvqGBEEIk4Q:ARo8fqewax4:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=VvqGBEEIk4Q:ARo8fqewax4:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?i=VvqGBEEIk4Q:ARo8fqewax4:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=VvqGBEEIk4Q:ARo8fqewax4:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?i=VvqGBEEIk4Q:ARo8fqewax4:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/hastobedotnet/~4/VvqGBEEIk4Q" height="1" width="1"/&gt;</description><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/handsfree/default.aspx">handsfree</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/phone/default.aspx">phone</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Nokia/default.aspx">Nokia</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Bluetooth/default.aspx">Bluetooth</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/car/default.aspx">car</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/iPhone/default.aspx">iPhone</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/iPhone4/default.aspx">iPhone4</category><feedburner:origLink>http://hastobe.net/blogs/stevemorgan/archive/2010/09/16/iphone-4-ios4-1-and-nokia-616-bluetooth-compatibility-problems.aspx</feedburner:origLink></item><item><title>Private Cloud ≠ Private Public Cloud</title><link>http://feedproxy.google.com/~r/hastobedotnet/~3/wAO-URpLfA4/private-cloud-private-public-cloud.aspx</link><pubDate>Fri, 10 Sep 2010 11:55:00 GMT</pubDate><guid isPermaLink="false">b3b1d9c2-f4c9-4970-bb5d-c90d4bed0aec:329</guid><dc:creator>Steve Morgan</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://hastobe.net/blogs/stevemorgan/rsscomments.aspx?PostID=329</wfw:commentRss><comments>http://hastobe.net/blogs/stevemorgan/archive/2010/09/10/private-cloud-private-public-cloud.aspx#comments</comments><description>&lt;h2&gt;Or when is a cloud not a cloud?&lt;/h2&gt;
&lt;p&gt;The economies afforded by using a public cloud arise from the utility pricing model where customers are charged only for the resources that they use. Maximum cost savings are made by minimising the resources that are consumed but with the benefit that, if additional resources are required, they are instantly available at a known cost. This is achievable for public cloud providers because a very large number of customers share a very large number of resources, each using a very small proportion. The cloud provider makes money through economies of scale as peaks average out and the amount of additional capacity required can be kept relatively small. Utilisation for a single customer is very low, but average utilisation for the cloud provider is relatively high.&lt;/p&gt;
&lt;p&gt;Compare this with a customer employing a private cloud. The private cloud is a shared resource, but can only be shared by the subset of applications within the customer estate that are cloud-ready. Because the cloud is private, the entire cost of the cloud falls to the customer, regardless of whether they are using the resources or not. Applying a utility cost model to a private cloud doesn&amp;rsquo;t work (or is risky, at least) because somebody has to pay for the unused resources. So, in order to realise maximum cost benefit, utilisation of the private cloud must be as high as possible. But if utilisation is kept high, one of the major benefits of the cloud is lost; immediate elasticity. If the unthinkable happens (that the private cloud runs out of resource) the situation for customers is potentially worse than in a non-cloud environment as the lead time to procure and deploy additional nodes for a private cloud are potentially longer than procuring commodity servers. In order to mitigate the risk, there may be a tendency for service owners to want to ring-fence cloud resources, creating their own private cloud, and simply exacerbating the problem. Simply, the bigger the cloud, the more cost effective it is. As the size of a cloud reduces, it becomes nothing more than a standardised infrastructure platform offering a number of middleware services.&lt;/p&gt;
&lt;p&gt;There are important differentiators between public and private clouds with advantages and disadvantages to each. Major candidates for private clouds include the public sector. But maybe greater benefit&amp;nbsp;could be gained by promoting the use of a G-Cloud, an accredited cloud resource that is shared across&amp;nbsp;the public sector but delivered by an accredited cloud service provider. I think I may know of such a service provider...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://hastobe.net/aggbug.aspx?PostID=329" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=wAO-URpLfA4:4HlaqqJ6m0M:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=wAO-URpLfA4:4HlaqqJ6m0M:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?i=wAO-URpLfA4:4HlaqqJ6m0M:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=wAO-URpLfA4:4HlaqqJ6m0M:l6gmwiTKsz0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?d=l6gmwiTKsz0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=wAO-URpLfA4:4HlaqqJ6m0M:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=wAO-URpLfA4:4HlaqqJ6m0M:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?i=wAO-URpLfA4:4HlaqqJ6m0M:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=wAO-URpLfA4:4HlaqqJ6m0M:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?i=wAO-URpLfA4:4HlaqqJ6m0M:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/hastobedotnet/~4/wAO-URpLfA4" height="1" width="1"/&gt;</description><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Azure/default.aspx">Azure</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Cloud/default.aspx">Cloud</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/PaaS/default.aspx">PaaS</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Public+Sector/default.aspx">Public Sector</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Public+Cloud/default.aspx">Public Cloud</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Private+Cloud/default.aspx">Private Cloud</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Iaas/default.aspx">Iaas</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Cloud+Computing/default.aspx">Cloud Computing</category><feedburner:origLink>http://hastobe.net/blogs/stevemorgan/archive/2010/09/10/private-cloud-private-public-cloud.aspx</feedburner:origLink></item><item><title>How much to run my app on Windows Azure? - Part 1</title><link>http://feedproxy.google.com/~r/hastobedotnet/~3/wzDSftJQAOQ/how-much-to-run-my-app-on-windows-azure-part-1.aspx</link><pubDate>Sun, 22 Aug 2010 22:09:00 GMT</pubDate><guid isPermaLink="false">b3b1d9c2-f4c9-4970-bb5d-c90d4bed0aec:319</guid><dc:creator>Steve Morgan</dc:creator><slash:comments>1</slash:comments><wfw:commentRss>http://hastobe.net/blogs/stevemorgan/rsscomments.aspx?PostID=319</wfw:commentRss><comments>http://hastobe.net/blogs/stevemorgan/archive/2010/08/22/how-much-to-run-my-app-on-windows-azure-part-1.aspx#comments</comments><description>&lt;p&gt;&lt;i&gt;or how accurately do you need to estimate?&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;Windows Azure (previously codenamed Red Dog) is Microsoft&amp;rsquo;s foray into Platform-as-a-Service (PaaS). Rather than incurring large amounts of capital expenditure building, hosting and maintaining a mountain of infrastructure, Azure opens up the possibility of moving our applications to an environment of virtually limitless capacity (within reason) where organisations pay for only the resources that they use on an hour-by-hour basis. &lt;br /&gt;&lt;br /&gt;Azure promises capacity to meet every conceivable demand for computing and storage (as long as it&amp;rsquo;s running on Windows) yet saving the consumers significant amounts of money. In these austere times, when all budgets are under considerable pressure, that&amp;rsquo;s a pretty appealing prospect.&lt;br /&gt;&lt;br /&gt;The problem is that offering our customers a solution that reduces cost always leads to one tricky question:&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&amp;ldquo;How much?&amp;rdquo;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;Ooh, the killer question! There are, of course, a great many factors that influence the cost of bringing an application into service and running it for the entirety of it&amp;rsquo;s life expectancy. I&amp;rsquo;m going to touch on just the costs of delivering the infrastructure and running it for some arbitrary period of time.&lt;br /&gt;&lt;br /&gt;There are two major influencers to the overall shape and size of any given infrastructure; the functions is must fulfil and the capacity it must provide.&lt;br /&gt;&lt;br /&gt;Functionally, an infrastructure must include networks, routing, load balancing, computing resource, storage and backup capabilities. Many applications can operate perfectly effectively on a fairly standard or &amp;lsquo;commodity&amp;rsquo; infrastructure. Others may have more exotic requirements; maybe some special hardware like a telephony system (PBX) or data gathering device. If this is the case for your application, you can forget hosting your application lock-stock-and-barrel in the cloud, at least for now. A hybrid cloud and on-premise solution may be a viable option, but I&amp;rsquo;m going to avoid discussion of such mongrels for now.&lt;br /&gt;&lt;br /&gt;Computing in the cloud is about running your applications on an arbitrary slice of tons-and-tons of commodity infrastructure.&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&amp;ldquo;Yeah, but how much?&amp;rdquo;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;In my experience, customers need to know before committing to a project how much it&amp;rsquo;s going to cost them. Sizing infrastructure early in a project&amp;rsquo;s lifecycle is always a bit of a black art. Customers often don&amp;rsquo;t really know how many users their applications are going to support. They don&amp;rsquo;t know the blend of transactions that are going to be executed. We (the technical experts), don&amp;rsquo;t know how we&amp;rsquo;re going to implement what the customer&amp;rsquo;s asked for, either because they&amp;rsquo;ve not yet told us enough or we haven&amp;rsquo;t yet worked out how we&amp;rsquo;re going to build it.&lt;br /&gt;&lt;br /&gt;Being the long-established experts that we are, we apply three key techniques to identifying the optimal infrastructure capacity for any given problem domain:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Experience&lt;/li&gt;
&lt;li&gt;Guesswork&lt;/li&gt;
&lt;li&gt;The Fudge-Factor&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;br /&gt;The amount and the nature of the experience you have is obviously going to have a massive impact on the effectiveness of point 1 in this list. If this solution is to all intent and purpose one that you&amp;rsquo;ve delivered time and time again, you&amp;rsquo;ll have a really strong baseline against which to assess the cost. In my experience, unless you&amp;rsquo;re delivering vertical solutions, you never really do the same thing twice. Experience will help you estimate those aspects that are similar to things you have delivered before. Experience will also give you some inkling as to how hard the bits that you don&amp;rsquo;t know are likely to be.&lt;br /&gt;&lt;br /&gt;After experience comes guesswork. Hopefully, you&amp;rsquo;ll know enough to keep the guesswork to a minimum, because this is where the biggest risk to the accuracy of your estimate hangs out.&lt;br /&gt;&lt;br /&gt;Finally, we introduce the fudge-factor. This might otherwise be known as contingency. If your experience and guesswork leads you to the conclusion that your database server needs two processors and 4GB RAM, let&amp;rsquo;s specify four processors and 8GB RAM &amp;ndash; just to be on the safe side.&lt;br /&gt;&lt;br /&gt;If you&amp;rsquo;re lucky, the scale of the infrastructure you come up with will cope with the actual load (at least until you&amp;rsquo;re safely ensconced elsewhere). If you were smart, you&amp;rsquo;ll have architected the solution to scale by simply adding more hardware at a later date (never mind the cost).&lt;br /&gt;&lt;br /&gt;Now, what happens if you over-estimate the scale of the infrastructure that&amp;rsquo;s required to effectively carry the load? Typically, nobody will ever know! All the customer will know is that the application continues to be provide the performance they expected yet cope admirably with the ever increasing number of users. They&amp;rsquo;ll never realise that the reason they&amp;rsquo;re having to cut investment in future projects is because your application consumes no more than 10% of the hardware that they&amp;rsquo;ve paid (and continue to pay) for.&lt;br /&gt;&lt;br /&gt;Now, think about what happens when they&amp;rsquo;re being billed my Microsoft for running their application in the cloud. &lt;br /&gt;&lt;br /&gt;The first problem is that, for the moment at least, hardly anyone has experience of the costs associated with running applications on Azure. We can compensate by increasing our reliance on guesswork and the fudge-factor. We can still produce a cost. And if our project goes ahead, one of three things will happen:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Our estimate will be &amp;lsquo;in the right ballpark&amp;rsquo; and everyone will be happy.&lt;/li&gt;
&lt;li&gt;Our estimate will be way too low and someone is going to get a really nasty surprise when the bills from Microsoft start rolling in.&lt;/li&gt;
&lt;li&gt;Our estimate will be way too high.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;br /&gt;On the face of it, point 3 seems just fine. After all, we&amp;rsquo;ve set a level of expectation for the cost of running this application and it&amp;rsquo;s turned out to be much cheaper. &lt;br /&gt;&lt;br /&gt;But let&amp;rsquo;s think about this more critically. When we put forward our estimate to the business sponsor, they (or maybe the CFO) had to assess the cost-benefit of proceeding with the project at all. Best case, you&amp;rsquo;ve made the business sponsor feel a fool for jumping through hoops to get financial approval for a project that may otherwise have slipped &amp;lsquo;under the RADAR&amp;rsquo;. Worst case, the project never got the green light anyway because the ROI wasn&amp;rsquo;t sufficient. &lt;br /&gt;&lt;br /&gt;The other issue, the one that is more personal, is that you&amp;rsquo;ve made it blindingly obvious that you don&amp;rsquo;t know what you&amp;rsquo;re doing; your credibility and reputation are indelibly tarnished. I don&amp;#39;t know about you, but even if I don&amp;#39;t know what I&amp;#39;m doing, I don&amp;#39;t really like to be found out!&lt;br /&gt;&lt;br /&gt;When we&amp;rsquo;re designing for the cloud, we need to take a much more robust and scientific approach to estimate the operational costs for any solution that we assess. In part 2, I&amp;rsquo;ll explore some of the specific things I think we should be considering and wondering about just how we&amp;rsquo;re going to pull it off.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://hastobe.net/aggbug.aspx?PostID=319" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=wzDSftJQAOQ:W54_wwjA2nU:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=wzDSftJQAOQ:W54_wwjA2nU:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?i=wzDSftJQAOQ:W54_wwjA2nU:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=wzDSftJQAOQ:W54_wwjA2nU:l6gmwiTKsz0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?d=l6gmwiTKsz0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=wzDSftJQAOQ:W54_wwjA2nU:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=wzDSftJQAOQ:W54_wwjA2nU:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?i=wzDSftJQAOQ:W54_wwjA2nU:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=wzDSftJQAOQ:W54_wwjA2nU:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?i=wzDSftJQAOQ:W54_wwjA2nU:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/hastobedotnet/~4/wzDSftJQAOQ" height="1" width="1"/&gt;</description><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Azure/default.aspx">Azure</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Windows+Azure/default.aspx">Windows Azure</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Cloud/default.aspx">Cloud</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Platform-as-a-Service/default.aspx">Platform-as-a-Service</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Estimating/default.aspx">Estimating</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Infrastructure/default.aspx">Infrastructure</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/PaaS/default.aspx">PaaS</category><feedburner:origLink>http://hastobe.net/blogs/stevemorgan/archive/2010/08/22/how-much-to-run-my-app-on-windows-azure-part-1.aspx</feedburner:origLink></item><item><title>Getting to Know Windows Azure</title><link>http://feedproxy.google.com/~r/hastobedotnet/~3/tvlybS7pWE8/getting-to-know-windows-azure.aspx</link><pubDate>Sun, 22 Aug 2010 20:06:00 GMT</pubDate><guid isPermaLink="false">b3b1d9c2-f4c9-4970-bb5d-c90d4bed0aec:318</guid><dc:creator>Steve Morgan</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://hastobe.net/blogs/stevemorgan/rsscomments.aspx?PostID=318</wfw:commentRss><comments>http://hastobe.net/blogs/stevemorgan/archive/2010/08/22/getting-to-know-windows-azure.aspx#comments</comments><description>&lt;p&gt;I consider myself rather lucky at the moment. I was recently amongst forty-four &amp;lsquo;carefully selected&amp;rsquo; specialists within my organisation to spend a week at Microsoft&amp;rsquo;s pleasure in Redmond to kick-start our Windows Azure partnership. We forty-four &lt;i&gt;good men and true&lt;/i&gt; (and women) were apparently selected because we&amp;rsquo;re the &amp;lsquo;best of the best&amp;rsquo;. Though my suspicion is that in certain cases, it&amp;rsquo;s because we were the &amp;lsquo;most of the available&amp;rsquo;.&lt;br /&gt;&lt;br /&gt;This was my first deep immersion into Windows Azure, though I&amp;rsquo;d been doing a little homework beforehand. There&amp;rsquo;s a lot to know. Sure, at a simplistic level, it&amp;rsquo;s a virtualized, massively scalable environment for running new or existing applications. But if you think that&amp;rsquo;s all there is to it, you&amp;rsquo;re going to be in for a nasty surprise. Us architects, especially, need to raise our game and get to know Windows Azure (and cloud computing in general) in intimate detail if our customers aren&amp;rsquo;t going to be in for some nasty surprises.&lt;br /&gt;&lt;br /&gt;In upcoming posts, I shall be talking more about moving to Azure and what that means for Sales, Architecture, Development and Service Management, because Azure cuts across all of these disciplines.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://hastobe.net/aggbug.aspx?PostID=318" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=tvlybS7pWE8:_S79tteoAPI:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=tvlybS7pWE8:_S79tteoAPI:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?i=tvlybS7pWE8:_S79tteoAPI:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=tvlybS7pWE8:_S79tteoAPI:l6gmwiTKsz0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?d=l6gmwiTKsz0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=tvlybS7pWE8:_S79tteoAPI:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=tvlybS7pWE8:_S79tteoAPI:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?i=tvlybS7pWE8:_S79tteoAPI:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=tvlybS7pWE8:_S79tteoAPI:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?i=tvlybS7pWE8:_S79tteoAPI:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/hastobedotnet/~4/tvlybS7pWE8" height="1" width="1"/&gt;</description><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Azure/default.aspx">Azure</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Windows+Azure/default.aspx">Windows Azure</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Cloud/default.aspx">Cloud</category><feedburner:origLink>http://hastobe.net/blogs/stevemorgan/archive/2010/08/22/getting-to-know-windows-azure.aspx</feedburner:origLink></item><item><title>Starbucks finally gets rid of T-Mobile. iPhone users rejoice!</title><link>http://feedproxy.google.com/~r/hastobedotnet/~3/slEy7SEr-g0/starbucks-finally-gets-rid-of-t-mobile-iphone-users-rejoice.aspx</link><pubDate>Fri, 15 May 2009 07:35:00 GMT</pubDate><guid isPermaLink="false">b3b1d9c2-f4c9-4970-bb5d-c90d4bed0aec:94</guid><dc:creator>Steve Morgan</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://hastobe.net/blogs/stevemorgan/rsscomments.aspx?PostID=94</wfw:commentRss><comments>http://hastobe.net/blogs/stevemorgan/archive/2009/05/15/starbucks-finally-gets-rid-of-t-mobile-iphone-users-rejoice.aspx#comments</comments><description>&lt;p&gt;I&amp;#39;d heard a mention that things were changing in Starbucks.&lt;/p&gt;
&lt;p&gt;This morning, I had the great&amp;nbsp;displeasure of dealing with T-Mobile&amp;#39;s hotspot customer support when unable to connect from my local Starbucks. I use an iPass-enabled laptop for work, which makes working in Starbucks generally easy. But not today. Once again, I had to explain to the customer service representative that the IP address I&amp;nbsp;had&amp;nbsp;really was from their hotspot. &amp;quot;Oh, but our IP addresses always start 10.113, Mr. Morgan&amp;quot;. Once they finally acknowledged that there was a problem, I then have to wait 24-48 hours while they think about fixing it. At which point, they&amp;#39;ll undoubtedly get someone in Starbucks to recycle the power and the problem will go away.&lt;/p&gt;
&lt;p&gt;This is a relatively new branch of Starbucks and the T-Mobile hotspot has been a regular problem since it opened. I&amp;#39;ve literally spent hours on the phone to their customer support trying to get them to sort it out. Of course, being &amp;quot;a member of the public&amp;quot;, I can&amp;#39;t possibly know what I&amp;#39;m talking about. You get used to being patronised after a while.&lt;/p&gt;
&lt;p&gt;Thankfully, however, the curse of T-Mobile is shortly to disappear from Starbucks. Having finally brokered the relevant deals, Starbucks in the UK is moving to BT Openzone for it&amp;#39;s hotspots. To be honest, I don&amp;#39;t really know if BT Openzone is going to be any more reliable. Or if their customer service is better.&lt;/p&gt;
&lt;p&gt;What I do know, though, is that it&amp;#39;s good news for us iPhone users. At last,&amp;nbsp;from May 25th, I can have complimentary iPhone Wi-Fi access with my Caramel Macchiato. Which will hopefully be much much responsive that O2&amp;#39;s&amp;nbsp;patchy 3G coverage.&lt;/p&gt;
&lt;p&gt;In the meantime, while I wait patiently for T-Mobile to fix the problem (or BT Openzone to replace it altogether), I&amp;#39;m having to fall back to my Vodafone 3G card. Still, at least it&amp;#39;s working.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://hastobe.net/aggbug.aspx?PostID=94" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=slEy7SEr-g0:rh6RpZsvh_k:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=slEy7SEr-g0:rh6RpZsvh_k:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?i=slEy7SEr-g0:rh6RpZsvh_k:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=slEy7SEr-g0:rh6RpZsvh_k:l6gmwiTKsz0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?d=l6gmwiTKsz0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=slEy7SEr-g0:rh6RpZsvh_k:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=slEy7SEr-g0:rh6RpZsvh_k:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?i=slEy7SEr-g0:rh6RpZsvh_k:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=slEy7SEr-g0:rh6RpZsvh_k:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?i=slEy7SEr-g0:rh6RpZsvh_k:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/hastobedotnet/~4/slEy7SEr-g0" height="1" width="1"/&gt;</description><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/iPhone/default.aspx">iPhone</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Starbucks/default.aspx">Starbucks</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/T-Mobile/default.aspx">T-Mobile</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Hotspot/default.aspx">Hotspot</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/BT+Openzone/default.aspx">BT Openzone</category><feedburner:origLink>http://hastobe.net/blogs/stevemorgan/archive/2009/05/15/starbucks-finally-gets-rid-of-t-mobile-iphone-users-rejoice.aspx</feedburner:origLink></item><item><title>Microsoft ships an iPhone app!</title><link>http://feedproxy.google.com/~r/hastobedotnet/~3/PUanm_Y8tNs/microsoft-ships-an-iphone-app.aspx</link><pubDate>Wed, 17 Dec 2008 20:02:00 GMT</pubDate><guid isPermaLink="false">b3b1d9c2-f4c9-4970-bb5d-c90d4bed0aec:42</guid><dc:creator>Steve Morgan</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://hastobe.net/blogs/stevemorgan/rsscomments.aspx?PostID=42</wfw:commentRss><comments>http://hastobe.net/blogs/stevemorgan/archive/2008/12/17/microsoft-ships-an-iphone-app.aspx#comments</comments><description>&lt;p&gt;Well, who would have thought that Microsoft would get into iPhone development?&lt;/p&gt;
&lt;p&gt;&lt;span id="intelliTXT"&gt;On 13th December 2008, Microsoft Live Labs &lt;a target="_blank" href="http://livelabs.com/blog/seadragon-goes-mobile/"&gt;announced&lt;/a&gt; the launch of a &lt;/span&gt;&lt;span id="intelliTXT"&gt;preview release of &lt;/span&gt;&lt;span id="intelliTXT"&gt;its Seadragon Mobile application for the iPhone.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Seadragon Mobile provides smooth image viewing and scaling, just like we&amp;#39;re used to seeing on the iPhone with Google Maps.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;It makes sense that the iPhone&amp;#39;s the first mobile platform to get such an app. It&amp;#39;s powerful UI is a natural for it. Blackberries and Nokias just don&amp;#39;t have the graphics capability. What&amp;#39;s interesting, though, is that there&amp;#39;s no sign of a version for Windows Mobile yet.&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve been having a play with it and, while it&amp;#39;s not going to set the world alight, it&amp;#39;s nice to see that Microsoft are mature enough to recognise that the iPhone is a viable platform for their technology.&lt;/p&gt;
&lt;p&gt;&lt;span id="intelliTXT"&gt;
&lt;p&gt;You can download Seadragon Mobile for free&amp;nbsp; from the &lt;a target="_blank" href="http://appshopper.com/photography/seadragon-mobile"&gt;Apple iTunes App Store&lt;/a&gt;.    &lt;/p&gt;
&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://hastobe.net/aggbug.aspx?PostID=42" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=PUanm_Y8tNs:RjJ6lDAtwcM:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=PUanm_Y8tNs:RjJ6lDAtwcM:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?i=PUanm_Y8tNs:RjJ6lDAtwcM:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=PUanm_Y8tNs:RjJ6lDAtwcM:l6gmwiTKsz0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?d=l6gmwiTKsz0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=PUanm_Y8tNs:RjJ6lDAtwcM:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=PUanm_Y8tNs:RjJ6lDAtwcM:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?i=PUanm_Y8tNs:RjJ6lDAtwcM:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=PUanm_Y8tNs:RjJ6lDAtwcM:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?i=PUanm_Y8tNs:RjJ6lDAtwcM:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/hastobedotnet/~4/PUanm_Y8tNs" height="1" width="1"/&gt;</description><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/iPhone/default.aspx">iPhone</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Seadragon/default.aspx">Seadragon</category><feedburner:origLink>http://hastobe.net/blogs/stevemorgan/archive/2008/12/17/microsoft-ships-an-iphone-app.aspx</feedburner:origLink></item><item><title>HowTo: Insert an image into a Word document and display it using OpenXML</title><link>http://feedproxy.google.com/~r/hastobedotnet/~3/zUecTUtUP6E/howto-insert-an-image-into-a-word-document-and-display-it-using-openxml.aspx</link><pubDate>Mon, 15 Sep 2008 11:01:00 GMT</pubDate><guid isPermaLink="false">b3b1d9c2-f4c9-4970-bb5d-c90d4bed0aec:22</guid><dc:creator>Steve Morgan</dc:creator><slash:comments>5</slash:comments><description>&lt;p&gt;One of the tasks I&amp;#39;ve had over the last few weeks has been to automatically generate documentation from an architectural model. It&amp;#39;s been (and continues to be) a relatively painful, sluggish process, as I&amp;#39;m generating Microsoft Word 2007 documents using the Open XML SDK. Never more so than when I came to add support for including images.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m going to do a 10,000&amp;#39; pass through the way that I approached it, so it&amp;#39;s not a beginners guide to OpenXML. You&amp;#39;re going to need to be able to find your way around an OpenXML document using the Open XML SDK first. &lt;/p&gt;
&lt;p&gt;The basic process I&amp;#39;m using is to generate from my architectural model an XML document that will ultimately become a Microsoft Word document, like this:&lt;/p&gt;
&lt;div class="xml xml" style="BORDER-RIGHT:#d0d0d0 1px solid;BORDER-TOP:#d0d0d0 1px solid;BORDER-LEFT:#d0d0d0 1px solid;COLOR:#006;BORDER-BOTTOM:#d0d0d0 1px solid;FONT-FAMILY:monospace;BACKGROUND-COLOR:#f0f0f0;"&gt;
&lt;ol&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;?xml&lt;/span&gt; &lt;span class="re0"&gt;version&lt;/span&gt;=&lt;span class="st0"&gt;&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span class="re0"&gt;encoding&lt;/span&gt;=&lt;span class="st0"&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt; &lt;span class="re2"&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;content&lt;/span&gt; &lt;span class="re0"&gt;xmlns:w&lt;/span&gt;=&lt;span class="st0"&gt;&amp;quot;http://schemas.openxmlformats.org/wordprocessingml/2006/main&amp;quot;&lt;/span&gt;&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;bookmark&lt;/span&gt; &lt;span class="re0"&gt;id&lt;/span&gt;=&lt;span class="st0"&gt;&amp;quot;ContentToReplace&amp;quot;&lt;/span&gt;&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;para&lt;/span&gt; &lt;span class="re0"&gt;style&lt;/span&gt;=&lt;span class="st0"&gt;&amp;quot;Heading1&amp;quot;&lt;/span&gt;&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;Major Heading&lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;/para&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li2"&gt;
&lt;div class="de2"&gt;&amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;para&lt;/span&gt; &lt;span class="re0"&gt;style&lt;/span&gt;=&lt;span class="st0"&gt;&amp;quot;Heading2&amp;quot;&lt;/span&gt;&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;Secondary Heading&lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;/para&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;table&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;tr&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;td&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;para&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Name&lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;/para&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li2"&gt;
&lt;div class="de2"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;/td&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;td&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;para&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Steve Morgan&lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;/para&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;/td&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;/tr&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li2"&gt;
&lt;div class="de2"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;tr&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;td&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;para&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Address&lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;/para&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;/td&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;td&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li2"&gt;
&lt;div class="de2"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;para&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;www.hastobe.net&lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;/para&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;para&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Somewhere in Hyperspace&lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;/para&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;/td&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;/tr&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;/table&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li2"&gt;
&lt;div class="de2"&gt;&amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;para&lt;/span&gt; &lt;span class="re0"&gt;style&lt;/span&gt;=&lt;span class="st0"&gt;&amp;quot;Heading2&amp;quot;&lt;/span&gt;&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;Another Secondary Heading&lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;/para&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;image&lt;/span&gt; &lt;span class="re0"&gt;src&lt;/span&gt;=&lt;span class="st0"&gt;&amp;quot;..\..\testfiles\mypic.png&amp;quot;&lt;/span&gt;&lt;span class="re2"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;para&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Good now, sit down, and tell me, he that knows,&lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;/para&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;para&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Why this same strict and most observant watch&lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;/para&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;para&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;So nightly toils the subject of the land,&lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;/para&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li2"&gt;
&lt;div class="de2"&gt;&amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;para&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;And why such daily cast of brazen cannon,&lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;/para&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;para&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;And foreign mart for implements of war;&lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;/para&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;para&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Why such impress of shipwrights, whose sore task&lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;/para&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;para&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Does not divide the Sunday from the week;&lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;/para&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;para&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;What might be toward, that this sweaty haste&lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;/para&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li2"&gt;
&lt;div class="de2"&gt;&amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;para&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Doth make the night joint-labourer with the day:&lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;/para&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;para&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Who is&amp;#39;t that can inform me?&lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;/para&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;/bookmark&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;/content&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;p&gt;I have some code that rips through a Word template document, looking for bookmarks and&amp;nbsp;replacing the content of those bookmarks with Open XML fragments. The fragments themselves are derived from the above XML structure using nothing more than good old-fashioned XSLT.&lt;/p&gt;
&lt;p&gt;Generating paragraphs of text and tables is pretty simple, as other than transforming the XML and inserting the resulting Open XML into the document, there&amp;#39;s not much to it.&lt;/p&gt;
&lt;p&gt;Images, on the other hand,&amp;nbsp;are a little more complicated. There are two stages to adding an image to a Word document (or any Open XML document, for that matter). The first is that you must add an &amp;quot;Image Part&amp;quot; that holds the binary representation of the image, itself. Finding out how to do that was pretty easy:&lt;/p&gt;
&lt;div class="csharp csharp" style="BORDER-RIGHT:#d0d0d0 1px solid;BORDER-TOP:#d0d0d0 1px solid;BORDER-LEFT:#d0d0d0 1px solid;COLOR:#006;BORDER-BOTTOM:#d0d0d0 1px solid;FONT-FAMILY:monospace;BACKGROUND-COLOR:#f0f0f0;"&gt;
&lt;ol&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;WordProcessingDocument m_Document = ...the document you&amp;#39;re building...&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;&lt;span class="kw1"&gt;public&lt;/span&gt; &lt;span class="kw4"&gt;void &lt;/span&gt;InsertImage&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="kw4"&gt;string&lt;/span&gt; imageFile, &lt;span class="kw4"&gt;string&lt;/span&gt; contentType&lt;span class="br0"&gt;)&lt;/span&gt;&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&lt;span class="br0"&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ImagePart part &lt;span class="sy0"&gt;=&lt;/span&gt; m_Document.&lt;span class="me1"&gt;MainDocumentPart&lt;/span&gt;.&lt;span class="me1"&gt;AddImagePart&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;contentType&lt;span class="br0"&gt;)&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li2"&gt;
&lt;div class="de2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kw1"&gt;using&lt;/span&gt; &lt;span class="br0"&gt;(&lt;/span&gt;FileStream stream &lt;span class="sy0"&gt;=&lt;/span&gt; &lt;a href="http://www.google.com/search?q=new+msdn.microsoft.com"&gt;&lt;span class="kw3"&gt;new&lt;/span&gt;&lt;/a&gt; FileStream&lt;span class="br0"&gt;(&lt;/span&gt;imageFile, FileMode.&lt;span class="me1"&gt;Open&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="br0"&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; part.&lt;span class="me1"&gt;FeedData&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;stream&lt;span class="br0"&gt;)&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="br0"&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&lt;span class="br0"&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;p class="li1"&gt;This function adds a new image part to the document and copies the content of the image file. However, getting the image displayed on the page is another matter entirely. It should be no surprise that we must add some markup to the main document to render the image. I created what I consider to be a minimal Open XML fragment that creates a single paragraph containing nothing but the requested image:&lt;/p&gt;
&lt;div class="xml xml" style="BORDER-RIGHT:#d0d0d0 1px solid;BORDER-TOP:#d0d0d0 1px solid;BORDER-LEFT:#d0d0d0 1px solid;COLOR:#006;BORDER-BOTTOM:#d0d0d0 1px solid;FONT-FAMILY:monospace;BACKGROUND-COLOR:#f0f0f0;"&gt;
&lt;ol&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;w:p&lt;/span&gt; &lt;span class="re0"&gt;xmlns:w&lt;/span&gt;=&lt;span class="st0"&gt;&amp;quot;http://schemas.openxmlformats.org/wordprocessingml/2006/main&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&lt;span class="sc3"&gt;&amp;nbsp; &amp;nbsp; &lt;span class="re0"&gt;xmlns:wp&lt;/span&gt;=&lt;span class="st0"&gt;&amp;quot;http://schemas.openxmlformats.org/drawingml/2006/&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; wordprocessingDrawing&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&lt;span class="sc3"&gt;&amp;nbsp; &amp;nbsp; &lt;span class="re0"&gt;xmlns:a&lt;/span&gt;=&lt;span class="st0"&gt;&amp;quot;http://schemas.openxmlformats.org/drawingml/2006/main&amp;quot;&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&lt;span class="sc3"&gt;&amp;nbsp; &amp;nbsp; &lt;span class="re0"&gt;xmlns:pic&lt;/span&gt;=&lt;span class="st0"&gt;&amp;quot;http://schemas.openxmlformats.org/drawingml/2006/picture&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li2"&gt;
&lt;div class="de2"&gt;&lt;span class="sc3"&gt;&amp;nbsp; &amp;nbsp; &lt;span class="re0"&gt;xmlns:r&lt;/span&gt;=&lt;span class="st0"&gt;&amp;quot;http://schemas.openxmlformats.org/officeDocument/2006/relationships&amp;quot;&lt;/span&gt;&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;w:r&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;w:drawing&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;wp:inline&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;wp:extent&lt;/span&gt; &lt;span class="re0"&gt;cx&lt;/span&gt;=&lt;span class="st0"&gt;&amp;quot;{WIDTH-IN-EMUS}&amp;quot;&lt;/span&gt; &lt;span class="re0"&gt;cy&lt;/span&gt;=&lt;span class="st0"&gt;&amp;quot;{HEIGHT-IN-EMUS}&amp;quot;&lt;/span&gt; &lt;span class="re2"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li2"&gt;
&lt;div class="de2"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;wp:docPr&lt;/span&gt; &lt;span class="re0"&gt;id&lt;/span&gt;=&lt;span class="st0"&gt;&amp;quot;{DRAWING-OBJECT-ID}&amp;quot;&lt;/span&gt; &lt;span class="re0"&gt;name&lt;/span&gt;=&lt;span class="st0"&gt;&amp;quot;{FILENAME-OF-IMAGE}&amp;quot;&lt;/span&gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="re0"&gt;descr&lt;/span&gt;=&lt;span class="st0"&gt;&amp;quot;An automatically inserted image&amp;quot;&lt;/span&gt; &lt;span class="re2"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;wp:cNvGraphicFramePr&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;a:graphicFrameLocks&lt;/span&gt; &lt;span class="re0"&gt;noChangeAspect&lt;/span&gt;=&lt;span class="st0"&gt;&amp;quot;1&amp;quot;&lt;/span&gt; &lt;span class="re2"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;/wp:cNvGraphicFramePr&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;a:graphic&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li2"&gt;
&lt;div class="de2"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;a:graphicData&lt;/span&gt; &lt;span class="re0"&gt;uri&lt;/span&gt;=&lt;span class="st0"&gt;&amp;quot;http://schemas.openxmlformats.org/drawingml/&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2006/picture&amp;quot;&lt;/span&gt;&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;pic:pic&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;pic:nvPicPr&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;pic:cNvPr&lt;/span&gt; &lt;span class="re0"&gt;id&lt;/span&gt;=&lt;span class="st0"&gt;&amp;quot;{PICTURE-ID}&amp;quot;&lt;/span&gt; &lt;span class="re0"&gt;name&lt;/span&gt;=&lt;span class="st0"&gt;&amp;quot;{FILENAME-OF-IMAGE}&amp;quot;&lt;/span&gt; &lt;span class="re2"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;pic:cNvPicPr&lt;/span&gt; &lt;span class="re2"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li2"&gt;
&lt;div class="de2"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;/pic:nvPicPr&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;pic:blipFill&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;a:blip&lt;/span&gt; &lt;span class="re0"&gt;r:embed&lt;/span&gt;=&lt;span class="st0"&gt;&amp;quot;{RELATIONSHIP-ID-OF-IMAGE-PART}&amp;quot;&lt;/span&gt; &lt;span class="re0"&gt;cstate&lt;/span&gt;=&lt;span class="st0"&gt;&amp;quot;print&amp;quot;&lt;/span&gt;&lt;span class="re2"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;a:stretch&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;a:fillRect&lt;/span&gt; &lt;span class="re2"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li2"&gt;
&lt;div class="de2"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;/a:stretch&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;/pic:blipFill&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;pic:spPr&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;a:xfrm&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;a:off&lt;/span&gt; &lt;span class="re0"&gt;x&lt;/span&gt;=&lt;span class="st0"&gt;&amp;quot;0&amp;quot;&lt;/span&gt; &lt;span class="re0"&gt;y&lt;/span&gt;=&lt;span class="st0"&gt;&amp;quot;0&amp;quot;&lt;/span&gt; &lt;span class="re2"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li2"&gt;
&lt;div class="de2"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;a:ext&lt;/span&gt; &lt;span class="re0"&gt;cx&lt;/span&gt;=&lt;span class="st0"&gt;&amp;quot;{WIDTH-IN-EMUS}&amp;quot;&lt;/span&gt; &lt;span class="re0"&gt;cy&lt;/span&gt;=&lt;span class="st0"&gt;&amp;quot;{HEIGHT-IN-EMUS}&amp;quot;&lt;/span&gt; &lt;span class="re2"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;/a:xfrm&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;a:prstGeom&lt;/span&gt; &lt;span class="re0"&gt;prst&lt;/span&gt;=&lt;span class="st0"&gt;&amp;quot;rect&amp;quot;&lt;/span&gt;&lt;span class="re2"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;/pic:spPr&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;/pic:pic&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li2"&gt;
&lt;div class="de2"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;/a:graphicData&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;/a:graphic&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;/wp:inline&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;/w:drawing&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;/w:r&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li2"&gt;
&lt;div class="de2"&gt;&lt;span class="sc3"&gt;&lt;span class="re1"&gt;&amp;lt;/w:p&lt;span class="re2"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;p&gt;Now, do you see those upper-case names in parenthesis (such as {WIDTH-IN-EMUS})? They&amp;#39;re placeholders for values that must be dynamically inserted and are derived as follows:&lt;/p&gt;

{WIDTH-IN-EMUS}

&lt;p&gt;That&amp;#39;s the width of the image. Not measured in terms of flightless birds, but English Metric Units. There are 914400 EMUs to the inch, so it&amp;#39;s calculated from:&lt;/p&gt;
&lt;pre&gt;widthInEmus = widthInPixels / HorizontalResolutionInDPI * 914400;&lt;/pre&gt;

{HEIGHT-IN-EMUS}

&lt;p&gt;Similarly, this is the height of the image in English Metric Units. Calculated from:&lt;/p&gt;
&lt;pre&gt;heightInEmus = heightInPixels / VerticalResolutionInDPI * 914400;&lt;/pre&gt;

{DRAWING-OBJECT-ID}

&lt;p&gt;This is a unique identifier for the Drawing Object. I calculate the initial value by looping through all of the existing &amp;lt;wp:docPr&amp;gt; elements in the document to find the largest Id, then increment it for each new image.&lt;/p&gt;

{FILENAME-OF-IMAGE}

&lt;p&gt;Just for the sake of convention, I put the terminal name of the image file in here.&lt;/p&gt;

{PICTURE-ID}

&lt;p&gt;This is a unique identifier for the Picture (as opposed to the Drawing Object - hmm?) and is derived in the same way as {DRAWING-OBJECT-ID} but from &amp;lt;pic:cNvPr&amp;gt; elements, not &amp;lt;wp:docPr&amp;gt;.&lt;/p&gt;

{RELATIONSHIP-ID-OF-IMAGE-PART}

&lt;p&gt;This is what binds the image placeholder in the document to the image resource that we&amp;#39;ve embedded in the new Image Part. To get it, we need to change our InsertImage function slightly:&lt;/p&gt;
&lt;div class="csharp csharp" style="BORDER-RIGHT:#d0d0d0 1px solid;BORDER-TOP:#d0d0d0 1px solid;BORDER-LEFT:#d0d0d0 1px solid;COLOR:#006;BORDER-BOTTOM:#d0d0d0 1px solid;FONT-FAMILY:monospace;BACKGROUND-COLOR:#f0f0f0;"&gt;
&lt;ol&gt;
&lt;li class="li1"&gt;&lt;span class="kw1"&gt;public&lt;/span&gt;&amp;nbsp;&lt;span class="kw4"&gt;string &lt;/span&gt;InsertImage&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="kw4"&gt;string&lt;/span&gt; imageFile, &lt;span class="kw4"&gt;string&lt;/span&gt; contentType&lt;span class="br0"&gt;)&lt;/span&gt;&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&lt;span class="br0"&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ImagePart part &lt;span class="sy0"&gt;=&lt;/span&gt; m_Document.&lt;span class="me1"&gt;MainDocumentPart&lt;/span&gt;.&lt;span class="me1"&gt;AddImagePart&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;contentType&lt;span class="br0"&gt;)&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li2"&gt;
&lt;div class="de2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kw1"&gt;using&lt;/span&gt; &lt;span class="br0"&gt;(&lt;/span&gt;FileStream stream &lt;span class="sy0"&gt;=&lt;/span&gt; &lt;a href="http://www.google.com/search?q=new+msdn.microsoft.com"&gt;&lt;span class="kw3"&gt;new&lt;/span&gt;&lt;/a&gt; FileStream&lt;span class="br0"&gt;(&lt;/span&gt;imageFile, FileMode.&lt;span class="me1"&gt;Open&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="br0"&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; part.&lt;span class="me1"&gt;FeedData&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;stream&lt;span class="br0"&gt;)&lt;/span&gt;;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="br0"&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&lt;span class="br0"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&lt;span class="br0"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kw3"&gt;return&lt;/span&gt;&lt;span class="me1"&gt; m_Document.MainDocumentPart.GetIdOfPart(part)&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1"&gt;
&lt;div class="de1"&gt;&lt;span class="br0"&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;br /&gt;The value returned by InsertImage is the Relationship Id that we insert into this attribute in the XML.
&lt;p&gt;So there you have it (for now). Equipped with your new Image Part and appropriate Open XML fragment, you should now to able to insert images, ad-nauseum, into your Open XML documents. I apologise for having skimmed over the subject at such a high level. Hopefully, I&amp;#39;ll get round to posting some more articles on Open XML that will fill in a few of the blanks. In the meantime, if you need some specific help, let me know.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://hastobe.net/aggbug.aspx?PostID=22" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=zUecTUtUP6E:lKFzH583uVk:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=zUecTUtUP6E:lKFzH583uVk:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?i=zUecTUtUP6E:lKFzH583uVk:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=zUecTUtUP6E:lKFzH583uVk:l6gmwiTKsz0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?d=l6gmwiTKsz0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=zUecTUtUP6E:lKFzH583uVk:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=zUecTUtUP6E:lKFzH583uVk:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?i=zUecTUtUP6E:lKFzH583uVk:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=zUecTUtUP6E:lKFzH583uVk:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?i=zUecTUtUP6E:lKFzH583uVk:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/hastobedotnet/~4/zUecTUtUP6E" height="1" width="1"/&gt;</description><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/OpenXML/default.aspx">OpenXML</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/CSharp/default.aspx">CSharp</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Imaging/default.aspx">Imaging</category><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/Microsoft+Word/default.aspx">Microsoft Word</category><feedburner:origLink>http://hastobe.net/blogs/stevemorgan/archive/2008/09/15/howto-insert-an-image-into-a-word-document-and-display-it-using-openxml.aspx</feedburner:origLink></item><item><title>It's called StackOverflow, it's good and it's coming soon!</title><link>http://feedproxy.google.com/~r/hastobedotnet/~3/btA7dn30ATw/it-s-called-stackoverflow-it-s-good-and-it-s-coming-soon.aspx</link><pubDate>Thu, 11 Sep 2008 15:26:00 GMT</pubDate><guid isPermaLink="false">b3b1d9c2-f4c9-4970-bb5d-c90d4bed0aec:17</guid><dc:creator>Steve Morgan</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://hastobe.net/blogs/stevemorgan/rsscomments.aspx?PostID=17</wfw:commentRss><comments>http://hastobe.net/blogs/stevemorgan/archive/2008/09/11/it-s-called-stackoverflow-it-s-good-and-it-s-coming-soon.aspx#comments</comments><description>&lt;p&gt;I&amp;#39;ve been following with interest the development of &lt;a class="" title="StackOverflow.com" href="http://www.stackoverflow.com/" target="_blank"&gt;StackOverflow.com&lt;/a&gt;, the brainchild of &lt;a class="" title="Jeff&amp;#39;s Coding Horror blog" href="http://www.codinghorror.com/" target="_blank"&gt;Jeff Attwood&lt;/a&gt; and &lt;a class="" title="Joel&amp;#39;s famous (infamous?) Joel On Software site" href="http://www.joelonsoftware.com/" target="_blank"&gt;Joel Spolsky&lt;/a&gt;, for a while now.&lt;/p&gt;
&lt;p&gt;It the time of writing, it&amp;#39;s still in beta. Hopefully, barring any further hiccups, it&amp;#39;ll be released to the great unwashed on Monday 15th September, 2008.&lt;/p&gt;
&lt;p&gt;StackOverflow is a Q&amp;amp;A site for developers. So what? Well, it&amp;#39;s &lt;strong&gt;really&lt;/strong&gt; slick. There&amp;#39;s loads of activity, plenty of good questions and plenty more good answers. The way the site&amp;#39;s been designed, it actively promotes high-quality content and discourages junk. I like it a lot.&lt;/p&gt;
&lt;p&gt;If you can&amp;#39;t wait until Monday (and I couldn&amp;#39;t), there&amp;#39;s information on how to access the beta on the &lt;a class="" title="Beta test post on the StackOverflow blog" href="http://blog.stackoverflow.com/2008/09/help-us-beta-test/" target="_blank"&gt;blog.stackoverflow.com&lt;/a&gt; site.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://hastobe.net/aggbug.aspx?PostID=17" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=btA7dn30ATw:MmxSsaWPURs:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=btA7dn30ATw:MmxSsaWPURs:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?i=btA7dn30ATw:MmxSsaWPURs:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=btA7dn30ATw:MmxSsaWPURs:l6gmwiTKsz0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?d=l6gmwiTKsz0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=btA7dn30ATw:MmxSsaWPURs:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=btA7dn30ATw:MmxSsaWPURs:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?i=btA7dn30ATw:MmxSsaWPURs:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/hastobedotnet?a=btA7dn30ATw:MmxSsaWPURs:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/hastobedotnet?i=btA7dn30ATw:MmxSsaWPURs:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/hastobedotnet/~4/btA7dn30ATw" height="1" width="1"/&gt;</description><category domain="http://hastobe.net/blogs/stevemorgan/archive/tags/StackOverflow/default.aspx">StackOverflow</category><feedburner:origLink>http://hastobe.net/blogs/stevemorgan/archive/2008/09/11/it-s-called-stackoverflow-it-s-good-and-it-s-coming-soon.aspx</feedburner:origLink></item></channel></rss>
