<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>PeterKellner.net &#187; Entity Framework</title>
	<atom:link href="http://peterkellner.net/category/entity-framework/feed/" rel="self" type="application/rss+xml" />
	<link>http://peterkellner.net</link>
	<description>Microsoft Focussed, JavaScript (ExtJS, SenchaTouch &#38; Windows 8 Metro)</description>
	<lastBuildDate>Tue, 07 Feb 2012 21:14:45 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>EntityFramework CodeFirst and AutoKey Generation</title>
		<link>http://peterkellner.net/2012/01/15/entityframework-codefirst-and-autokey-generation/</link>
		<comments>http://peterkellner.net/2012/01/15/entityframework-codefirst-and-autokey-generation/#comments</comments>
		<pubDate>Sun, 15 Jan 2012 21:02:45 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[CodeFirst]]></category>
		<category><![CDATA[Entity Framework]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2012/01/15/entityframework-codefirst-and-autokey-generation/</guid>
		<description><![CDATA[&#160;  This one had me a little stumped, and as usual, there are not enough examples in the Microsoft documentation to be very helpful. I’m using EntityFramework CodeFirst with Visual Studio 2011.&#160; Let’s assume you create a class as follows:  &#160;  public class CongressNumber
    {
     [...]]]></description>
			<content:encoded><![CDATA[<p>&#160;</p>  <p>This one had me a little stumped, and as usual, there are not enough examples in the <a href="http://www.microsoft.com/en-us/default.aspx">Microsoft</a> documentation to be very helpful. I’m using <a href="http://msdn.microsoft.com/en-us/data/aa937723">EntityFramework</a> <a href="http://msdn.microsoft.com/en-us/data/hh134698">CodeFirst</a> with <a href="http://www.microsoft.com/visualstudio/en-us/products/2010-editions">Visual Studio</a> 2011.&#160; Let’s assume you create a class as follows:</p>  <p>&#160;</p>  <pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> CongressNumber
    {
        [Key]
        <span class="kwrd">public</span> <span class="kwrd">int</span> CongressNumberValue { get; set; }
    }</pre>

<p><style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style></p>

<p>Then, you manually set the value of CongressNumberValue to 112.&#160; I’d certainly think that is a reasonable thing to do. I know that the Microsoft guys often special case Id or id, but hard to believe they would take something like CongressNumberValue and assume I meant that to be an autogenerating Identity column.&#160; Well, it seems they do that and the doc’s don’t even mention it.&#160; </p>

<p>After first, finding the <a href="http://msdn.microsoft.com/en-us/library/gg197525(v=vs.103).aspx">page on annotations</a>, I discovered that what we really need to set is this to have it work as we want (with no identity key generation).</p>

<pre class="csharpcode"> <span class="kwrd">public</span> <span class="kwrd">class</span> CongressNumber
    {
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.None)]
        <span class="kwrd">public</span> <span class="kwrd">int</span> CongressNumberValue { get; set; }
    }</pre>

<p>I found this after drilling down some in there doc.&#160; What surprises me is that no where does it mention that if you have a string, that does not get database generated, but if you have an int, that does.&#160; I wonder what happens if you have a Guid? (I’ll leave that up to someone who wants to use a guid).</p>

<p>I would have loved to put in my own comments on the page: <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.databasegeneratedoption(v=vs.103).aspx">http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.databasegeneratedoption(v=vs.103).aspx</a> but there was no user comment section.&#160; Oh well.</p>

<p>To be fair, on the page: <a href="http://msdn.microsoft.com/en-us/library/gg197525(v=vs.103).aspx">http://msdn.microsoft.com/en-us/library/gg197525(v=vs.103).aspx</a> it does explain about identity and integers but when I had my issue, I was already on the detail page.&#160; Seems to me the detail page should have more information on it than the summary page that leads in.&#160; The only reason I found it was because while writing this post, I went back to get the proper links.</p>

<p>&#160;</p>

<p><a href="http://peterkellner.net/wp/wp/wp-content/uploads/2012/01/image10.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/wp/wp/wp-content/uploads/2012/01/image_thumb8.png" width="542" height="89" /></a></p>

<p>HTH’s.</p>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2012/01/15/entityframework-codefirst-and-autokey-generation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>When Using EF CodeFirst With Visual Studio, How to Live With Cannot drop database because it is in use error.</title>
		<link>http://peterkellner.net/2012/01/15/when-using-ef-codefirst-with-visual-studio-how-to-live-with-cannot-drop-database-because-it-is-in-use-error/</link>
		<comments>http://peterkellner.net/2012/01/15/when-using-ef-codefirst-with-visual-studio-how-to-live-with-cannot-drop-database-because-it-is-in-use-error/#comments</comments>
		<pubDate>Sun, 15 Jan 2012 18:58:50 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[CodeFirst]]></category>
		<category><![CDATA[Entity Framework]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Sql Server]]></category>
		<category><![CDATA[Sql Server CE]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2012/01/15/when-using-ef-codefirst-with-visual-studio-how-to-live-with-cannot-drop-database-because-it-is-in-use-error/</guid>
		<description><![CDATA[   Problem   So, if you have been doing development with Visual Studio 2010, Entity Framework CodeFirst, SqlServer or SqlServerCE for any amount of time, you’ll quickly run into the problem that the database can not be reinitialized because it is open.&#160; Basically, the scenario is this.  1)&#160; Put in your [...]]]></description>
			<content:encoded><![CDATA[<h2>   <p>Problem</p> </h2>  <p>So, if you have been doing development with <a href="http://www.microsoft.com/visualstudio/en-us/products/2010-editions">Visual Studio 2010</a>, <a href="http://www.microsoft.com/download/en/details.aspx?displaylang=en&amp;id=8363">Entity Framework</a> <a href="http://msdn.microsoft.com/en-us/data/aa937723">CodeFirst</a>, <a href="http://www.microsoft.com/sqlserver/en/us/default.aspx">SqlServer</a> or <a href="http://en.wikipedia.org/wiki/SQL_Server_Compact">SqlServerCE</a> for any amount of time, you’ll quickly run into the problem that the database can not be reinitialized because it is open.&#160; Basically, the scenario is this.</p>  <p>1)&#160; Put in your <a href="http://msdn.microsoft.com/en-us/library/2027ewzw.aspx">Global.asax.cs</a> file a line that always recreates the database (naturally because you are in a development mode and as you constantly change your model and seed data).&#160; The line is something like this:&#160; Database.SetInitializer(new <a href="http://msdn.microsoft.com/en-us/library/gg679506(v=vs.103).aspx">DropCreateDatabaseAlways</a>&lt;SiteDB&gt;());</p>  <p>2)&#160; Run your application with something like Debug/Run (All is fine)</p>  <p>3)&#160; Go into the database browser (either in Visual Studio or Enterprise Manager)&#160; and look at some data.</p>  <p>4)&#160; Run your application again and you will get this error: “[SqlException (0x80131904): Cannot drop database &quot;NewYorkTimesDb&quot; because it is currently in use.]”.&#160; This is because your database browser has a connection to the database and until it is dropped, you can not drop the catalog.</p>  <p>&#160;</p>  <p><a href="http://peterkellner.net/wp/wp/wp-content/uploads/2012/01/image9.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/wp/wp/wp-content/uploads/2012/01/image_thumb7.png" width="574" height="199" /></a></p>  <p>&#160;</p>  <h2>Solutions</h2>  <p>&#160;</p>  <p>The easiest and guaranteed to work solution is just to restart your SqlServer database server (control panel, services).&#160; This is what I use to do but finally got tired of that because it takes about 20 seconds and, well, I’m very impatient.</p>  <p>The other solution <a href="http://stackoverflow.com/questions/11620/how-do-you-kill-all-current-connections-to-a-sql-server-2005-database">I found</a> in the forums (can’t find the link right now) is to execute the following script from the master database catalog:</p>  <pre class="csharpcode"><span class="kwrd">use</span> master
<span class="kwrd">ALTER</span> <span class="kwrd">DATABASE</span> NewYorkTimesDb 
   <span class="kwrd">SET</span> SINGLE_USER <span class="kwrd">WITH</span> <span class="kwrd">ROLLBACK</span> <span class="kwrd">IMMEDIATE</span> 
<span class="kwrd">ALTER</span> <span class="kwrd">DATABASE</span> NewYorkTimesDb <span class="kwrd">SET</span> MULTI_USER</pre>

<p>Basically, just switching from multi-user to single-user and back clears the connections.</p>

<p>HTH’s!<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style></p>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2012/01/15/when-using-ef-codefirst-with-visual-studio-how-to-live-with-cannot-drop-database-because-it-is-in-use-error/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I Love the Validation Error Messages I Get From EntityFramework CodeFirst 4.1!</title>
		<link>http://peterkellner.net/2011/12/13/i-love-the-validation-error-messages-i-get-from-entityframework-codefirst-4-1/</link>
		<comments>http://peterkellner.net/2011/12/13/i-love-the-validation-error-messages-i-get-from-entityframework-codefirst-4-1/#comments</comments>
		<pubDate>Wed, 14 Dec 2011 05:20:22 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[CodeFirst]]></category>
		<category><![CDATA[Entity Framework]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2011/12/13/i-love-the-validation-error-messages-i-get-from-entityframework-codefirst-4-1/</guid>
		<description><![CDATA[I’ve been using EntityFramework’s CodeFirst 4.1 on a new project I’ve been working.&#160; I plan to blog quite&#160; bit about it, but in the mean time I just felt the need to share.&#160; I’ve got some fairly complex code where I add an object tree to the database context (which turns into SqlServer data).&#160; When [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve been using <a href="http://msdn.microsoft.com/en-us/data/aa937723">EntityFramework’s</a> <a href="http://msdn.microsoft.com/en-us/data/gg685467">CodeFirst</a> 4.1 on a new project I’ve been working.&#160; I plan to blog quite&#160; bit about it, but in the mean time I just felt the need to share.&#160; I’ve got some fairly complex code where I add an object tree to the database context (which turns into SqlServer data).&#160; When I call db.SaveChanges(), I get an awesome error (see below) telling me exactly why it failed.</p>  <p>I’m currently on the honey moon with <a href="http://msdn.microsoft.com/en-us/data/hh134816">EF CodeFirst</a>.&#160; I only have about 10 tables (4 deep at most).&#160; Life is good.</p>&#160;&#160; <blockquote style="margin-right: 0px" dir="ltr"><a href="http://peterkellner.net/wp/wp/wp-content/uploads/2011/12/image6.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/wp/wp/wp-content/uploads/2011/12/image_thumb6.png" width="616" height="302" /></a></blockquote>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2011/12/13/i-love-the-validation-error-messages-i-get-from-entityframework-codefirst-4-1/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using The DataContext In EntityFramework To Retrieve Nested Objects</title>
		<link>http://peterkellner.net/2011/11/27/using-the-datacontext-in-entityframework-to-retrieve-nested-objects/</link>
		<comments>http://peterkellner.net/2011/11/27/using-the-datacontext-in-entityframework-to-retrieve-nested-objects/#comments</comments>
		<pubDate>Sun, 27 Nov 2011 18:41:22 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[CodeFirst]]></category>
		<category><![CDATA[Entity Framework]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2011/11/27/using-the-datacontext-in-entityframework-to-retrieve-nested-objects/</guid>
		<description><![CDATA[I’m always somewhat amazed when I read something from documentation that is not straight forward and it actually works.&#160; So amazed and excited that I often feel the need to blog about it.  So, here is the problem.&#160; I created a CodeFirst implementation of EntityFramework in Visual Studio and created a simple hierarchy in [...]]]></description>
			<content:encoded><![CDATA[<p>I’m always somewhat amazed when I read something from documentation that is not straight forward and it actually works.&#160; So amazed and excited that I often feel the need to blog about it.</p>  <p>So, here is the problem.&#160; I created a <a href="http://blogs.msdn.com/b/adonet/archive/2011/03/15/ef-4-1-code-first-walkthrough.aspx">CodeFirst</a> implementation of <a href="http://msdn.microsoft.com/en-us/data/aa937723">EntityFramework</a> in <a href="http://msdn.microsoft.com/en-us/vstudio/aa718325">Visual Studio</a> and created a simple hierarchy in my data model.&#160; That is, without showing all the code, here is what I have:</p>  <div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">   <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"><span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> Person<br />{<br />    [Key]<br />    [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]<br />    <span style="color: #0000ff">public</span> <span style="color: #0000ff">int</span> Id { get; set; }<br /><br />    <span style="color: #0000ff">public</span> <span style="color: #0000ff">virtual</span> List&lt;EmailAddressInfo&gt; EmailAddressInfoList { get; set; }<br />    ..<br />}<br /><br /><span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> EmailAddressInfo<br />{<br />    [Key]<br />    [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]<br />    <span style="color: #0000ff">public</span> <span style="color: #0000ff">int</span> Id { get; set; }<br /><br />    <span style="color: #0000ff">public</span> <span style="color: #0000ff">string</span> EmailAddress { get; set; }<br /><br />}<br /></pre>

  <br /></div>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"><span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> EmailAccount<br />{<br />    [Key]<br />    [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]<br />    <span style="color: #0000ff">public</span> <span style="color: #0000ff">int</span> Id { get; set; }<br />    ...<br />}</pre>

  <br /></div>

<p>Now, if you execute a LINQ command like the following:</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet">var recs = (from data <span style="color: #0000ff">in</span> db.Persons<br />                            select data);<br />                <span style="color: #0000ff">foreach</span> (var rec <span style="color: #0000ff">in</span> recs)<br />                {<br />                    <span style="color: #0000ff">foreach</span> (var email <span style="color: #0000ff">in</span> rec.EmailAddressInfoList)<br />                    {<br />                        Console.WriteLine(email);<br />                    }<br />                }</pre>

  <br /></div>

<p>You get the error:</p>

<blockquote>
  <p><b>Exception Details: </b><em>System.InvalidOperationException: There is already an open DataReader associated with this Command which must be closed first.</em></p>
</blockquote>

<p>&#160;</p>

<p><a href="http://peterkellner.net/wp/wp/wp-content/uploads/2011/11/image17.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/wp/wp/wp-content/uploads/2011/11/image_thumb16.png" width="579" height="181" /></a></p>

<p>&#160;</p>

<p>To solve this, you need to tell EntityFramework/CodeFirst to include the EmailAddressInfoList in the query.&#160; All you need to do is change the db.Persons to db.Persons.Include(&quot;EmailAddressInfoList&quot;) as follows:</p>

<p>&#160;</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet">var recs = (from data <span style="color: #0000ff">in</span> db.Persons.Include(<span style="color: #006080">&quot;EmailAddressInfoList&quot;</span>)<br />            select data);</pre>

  <br /></div>

<p>&#160;</p>

<p>Then, it all works!</p>

<p>Hope this helps.</p>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2011/11/27/using-the-datacontext-in-entityframework-to-retrieve-nested-objects/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Entity Framework&#8217;s CodeFirst Automatically Generates Foreign Keys For you</title>
		<link>http://peterkellner.net/2011/11/10/entity-frameworks-codefirst-automatically-generates-foreign-keys-for-you/</link>
		<comments>http://peterkellner.net/2011/11/10/entity-frameworks-codefirst-automatically-generates-foreign-keys-for-you/#comments</comments>
		<pubDate>Fri, 11 Nov 2011 06:24:11 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[CodeFirst]]></category>
		<category><![CDATA[Entity Framework]]></category>
		<category><![CDATA[Sql Server CE]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2011/11/10/entity-frameworks-codefirst-automatically-generates-foreign-keys-for-you/</guid>
		<description><![CDATA[I’ve been struggling with getting the EF CodeFirst right so that it automatically generates foreign keys when the tables are created. I had noticed that there is interesting syntax you can put in to create these foreign keys, however it seemed that the relationships are known so CodeFirst should do that for you.&#160; I won’t [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve been struggling with getting the <a href="http://msdn.microsoft.com/en-us/library/aa697427(v=vs.80).aspx">EF</a> CodeFirst right so that it automatically generates foreign keys when the tables are created. I had noticed that there is interesting syntax you can put in to create these foreign keys, however it seemed that the relationships are known so CodeFirst should do that for you.&#160; I won’t even bother to go through all the mistakes I made, but if you want to see one, you can check out my <a href="http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/a0c85adc-baa3-43fb-8323-4e9eabdfb237/">forum post</a> where I ask for help.</p>  <p>I’m currently writing a series of articles on building a <a href="http://www.sencha.com/">Sencha</a> <a href="http://www.sencha.com/products/extjs/">ExtJS</a> application with <a href="http://www.asp.net/">Microsoft ASP.NET</a> <a href="http://www.asp.net/mvc">MVC3</a>.&#160; I use <a href="http://msdn.microsoft.com/en-us/data/aa937723">codefirst</a> and at the moment I’m building a database of US Presidents and linking them to their Party (republican, democrat, etc.).&#160; So, the important thing is to link from the Presidents table to the Party Table and also from the Party to the President.&#160; Below is the code:</p>  <div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">   <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"><span style="color: #0000ff">namespace</span> SenchaDesignerExtension.Models<br />{<br />    <span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> Party<br />    {<br />        [Key]<br />        [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]<br />        <span style="color: #0000ff">public</span> <span style="color: #0000ff">int</span> Id { get; set; }<br /><br />        [MaxLengthAttribute(40)]<br />        <span style="color: #0000ff">public</span> <span style="color: #0000ff">string</span> Name { get; set; }<br />        <span style="color: #0000ff">public</span> <span style="color: #0000ff">virtual</span> ICollection&lt;President&gt; Presidents { get; set; } <br />    }<br /><br />    <span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> President<br />    {<br />        [Key]<br />        [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]<br />        <span style="color: #0000ff">public</span> <span style="color: #0000ff">int</span> Id { get; set; }<br /><br />        <span style="color: #0000ff">public</span> <span style="color: #0000ff">virtual</span> Party Party { get; set; }<br /><br />        <span style="color: #0000ff">public</span> <span style="color: #0000ff">int</span> PresidentNumber { get; set; }<br /><br />        [MaxLengthAttribute(20)]<br />        <span style="color: #0000ff">public</span> <span style="color: #0000ff">string</span> FirstName { get; set; }<br />        [MaxLengthAttribute(20)]<br />        <span style="color: #0000ff">public</span> <span style="color: #0000ff">string</span> LastName { get; set; }<br />        <span style="color: #0000ff">public</span> <span style="color: #0000ff">bool</span> Impeached { get; set; }<br />        <span style="color: #0000ff">public</span> DateTime TookOffice { get; set; }<br />        <span style="color: #0000ff">public</span> DateTime LeftOffice { get; set; }<br />        <span style="color: #0000ff">public</span> <span style="color: #0000ff">decimal</span>  Income { get; set; }<br />    } <br />}</pre>

  <br /></div>

<p>And, the repository is defined as follows:</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"><span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> USPresidentsDb : DbContext<br />{<br />     <span style="color: #0000ff">public</span> USPresidentsDb()<br />        : <span style="color: #0000ff">base</span>(<span style="color: #006080">&quot;name=USPresidents&quot;</span>)<br />    {<br />    }<br /><br />    <span style="color: #0000ff">public</span> DbSet&lt;UserInfo&gt; Users { get; set; }<br />    <span style="color: #0000ff">public</span> DbSet&lt;President&gt; Presidents { get; set; }<br />    <span style="color: #0000ff">public</span> DbSet&lt;Party&gt; Parties { get; set; }<br />    ...</pre>

  <br /></div>

<p>&#160;</p>

<p>Notice that in the party class, there is a virtual ICollection of Presidents, and notice in the President class, there is a virtual reference to the Party.&#160; These combined make the relationship work and the foreign key created.</p>

<p>If I look in my SQL Database, you’ll see a new foreign key is automatically created for me as Party_id.</p>

<p>&#160;</p>

<p><a href="http://peterkellner.net/wp/wp/wp-content/uploads/2011/11/image8.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/wp/wp/wp-content/uploads/2011/11/image_thumb7.png" width="205" height="244" /></a></p>

<p>I’m not exactly sure how SqlExpressCE shows foreign keys, but I know it is there because when I try to delete a Party record that is associated with a President I get the following error:</p>

<p>&#160;</p>

<p><a href="http://peterkellner.net/wp/wp/wp-content/uploads/2011/11/image9.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/wp/wp/wp-content/uploads/2011/11/image_thumb8.png" width="343" height="248" /></a></p>

<p>which tells me there is a constraint called Party_Presidents (my foreign key).</p>

<p>&#160;</p>

<p>So, it worked!&#160; If you want to see the full source for this, keep an eye on the series of articles I’m now writing (only the first one is done, but probably, by the time you find this, I’ll have others done that include this Presidents example.&#160; You can find the first one at the URL:&#160; <a title="http://peterkellner.net/2011/11/04/building-an-senchas-extjs-4-0-mvc-application-with-microsofts-asp-net-mvc3-series-basics/" href="http://peterkellner.net/2011/11/04/building-an-senchas-extjs-4-0-mvc-application-with-microsofts-asp-net-mvc3-series-basics/">http://peterkellner.net/2011/11/04/building-an-senchas-extjs-4-0-mvc-application-with-microsofts-asp-net-mvc3-series-basics/</a></p>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2011/11/10/entity-frameworks-codefirst-automatically-generates-foreign-keys-for-you/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Microsoft To Add Auto-Compiled LINQ Queries to Entity Framework V.Next!</title>
		<link>http://peterkellner.net/2011/10/22/microsoft-to-add-auto-compiled-linq-queries-to-entity-framework-v-next/</link>
		<comments>http://peterkellner.net/2011/10/22/microsoft-to-add-auto-compiled-linq-queries-to-entity-framework-v-next/#comments</comments>
		<pubDate>Sun, 23 Oct 2011 01:57:03 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[.NET 4.0]]></category>
		<category><![CDATA[.NET 4.5]]></category>
		<category><![CDATA[Entity Framework]]></category>
		<category><![CDATA[LINQ]]></category>
		<category><![CDATA[LINQ to SQL]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2011/10/22/microsoft-to-add-auto-compiled-linq-queries-to-entity-framework-v-next/</guid>
		<description><![CDATA[&#160;  In May of 2009 I discovered some significant performance problems that I blogged about.&#160; In summary, I had tracked it down to the issue of LINQ2SQ having to create a full expression tree on every instantiation of a LINQ2SQL query.&#160; I’m not a compiler write kind of guy but do respect the complexity [...]]]></description>
			<content:encoded><![CDATA[<p>&#160;</p>  <p>In May of 2009 I discovered some significant performance problems that I <a href="http://peterkellner.net/2009/05/06/linq-to-sql-slow-performance-compilequery-critical/">blogged</a> about.&#160; In summary, I had tracked it down to the issue of LINQ2SQ having to create a full expression tree on every instantiation of a LINQ2SQL query.&#160; I’m not a compiler write kind of guy but do respect the complexity of that and doing things like building expression trees, but still this really sucked.&#160; Using the compile syntax in LINQ2SQL is very awkward, and IMHO takes all the fun out of using LINQ2SQL.&#160; If you don’t remember my post, here is the graph showing the evil happening.</p>  <p>&#160;</p>  <p><a href="http://peterkellner.net/2009/05/06/linq-to-sql-slow-performance-compilequery-critical/"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/wp/wp/wp-content/uploads/2011/10/image6.png" width="285" height="173" /></a></p>  <p>So, what is a Microsoft MVP to do?&#160; I complained to everyone at Microsoft I knew.&#160; I made this my mission for about a year.&#160; I was told time after time that the problem was hugely complicated and no one was working on making it any faster.&#160; I just could not believe it because I felt this was such a barrier to success to <a href="http://msdn.microsoft.com/en-us/library/bb425822.aspx">LINQ2SQL</a> type technology (now <a href="http://msdn.microsoft.com/en-us/library/bb399572.aspx">Entity Framework</a> really) that Microsoft just could not ignore my findings.&#160; I was actually surprised that I was the only one screaming about this.</p>  <p>Well, quietly, <a href="http://blogs.msdn.com/b/adonet/archive/2011/10/18/how-we-talk-about-ef-and-its-future-versions.aspx">Microsoft has announced that in .Net Framework 4.5, Entity Framework will include “Auto-Compiled LINQ Queries”</a>.&#160; This is awesome!&#160;&#160; When it comes out, I’ll be testing and it giving feedback.</p>  <p>For now, I’m a very happy camper.</p>  <p>&#160;</p>  <p><a href="http://blogs.msdn.com/b/adonet/archive/2011/10/18/how-we-talk-about-ef-and-its-future-versions.aspx"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/wp/wp/wp-content/uploads/2011/10/image7.png" width="882" height="474" /></a></p>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2011/10/22/microsoft-to-add-auto-compiled-linq-queries-to-entity-framework-v-next/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Is There A Need For End-To-End ExtJS to Microsoft Server (MVC-C#, LOB) 4 Day Class? (Poll Enclosed)</title>
		<link>http://peterkellner.net/2010/05/04/lob-training-poll-using-extjs-dotnet-aspnet-mvc/</link>
		<comments>http://peterkellner.net/2010/05/04/lob-training-poll-using-extjs-dotnet-aspnet-mvc/#comments</comments>
		<pubDate>Wed, 05 May 2010 02:54:13 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[.NET 4.0]]></category>
		<category><![CDATA[ASP.NET 4.0]]></category>
		<category><![CDATA[Entity Framework]]></category>
		<category><![CDATA[ExtJS]]></category>
		<category><![CDATA[LINQ to SQL]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[OData]]></category>
		<category><![CDATA[Training]]></category>

		<guid isPermaLink="false">http://peterkellner.net/?p=1289</guid>
		<description><![CDATA[Over the past couple years, the focus of the web development I’ve been doing involves building highly flexible, highly scalable and straight forward web sites to implement and maintain Line of Business (LOB) applications.&#160; As you can probably tell from my posts, I’m very “practical” focused, and at the same time have a desire to [...]]]></description>
			<content:encoded><![CDATA[<p>Over the past couple years, the focus of the web development I’ve been doing involves building highly flexible, highly scalable and straight forward web sites to implement and maintain <a href="http://en.wikipedia.org/wiki/Line_of_business">Line of Business</a> (LOB) applications.&#160; As you can probably tell from my posts, I’m very “practical” focused, and at the same time have a desire to build awesome web applications.</p>  <p>The technology pairing I’ve chosen is <a href="http://www.asp.net/mvc/whatisaspmvc/">Microsoft’s .Net platform with MVC</a> on the server, and <a href="http://www.extjs.com/">ExtJS</a> on the client.&#160; Though it’s possible to still use ExtJS with standard html/aspx pages, I’ve found the best combination is to use 100% <a href="http://www.javascript.com/">JavaScript</a> on the client (ExtJS) and have all the server side technology be 100% service based.&#160; I’ve used <a href="http://msdn.microsoft.com/en-us/library/bb425822.aspx">LINQ2SQL</a> extensively as well as <a href="http://msdn.microsoft.com/en-us/magazine/ee336128.aspx">Entity Framework</a> in the latest <a href="http://msdn.microsoft.com/en-us/vstudio/default.aspx">Visual Studio 2010</a> release.</p>  <p>The learning curve was quite steep to actually be able to efficiently build highly flexible, highly scalable applications using these technologies, but now that I know it, I wouldn’t have it any other way.</p>  <p>I’m considering putting together a series of <strong>4 Day Classes</strong> around the country (or even world) that would basically teach people the methods and patterns I’ve learned and essentially leap frog a development team into being able to quickly do what it has taken me years to figure out.&#160; I’ve been fortunate enough to know the top 1% instructors and I’m sure with the right incentive, can get them to join me in both putting together these classes as well as teaching them.</p> <span id="more-1289"></span>  <p>So, my question is:</p> Note: There is a poll embedded within this post, please visit the site to participate in this post's poll.   <p>I really appreciate your feedback.&#160; If I go down this path, it will be a lot of work and it would be nice to know if people are really interested.&#160; I know for myself, I&#8217; would have gone to something like this 2 years ago and it would have saved me a lot of time.</p>  <p>Thanks for your feedback.</p>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2010/05/04/lob-training-poll-using-extjs-dotnet-aspnet-mvc/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Authentication and Authorization Using RIA Services (Article 7 of 7)</title>
		<link>http://peterkellner.net/2010/01/25/authentication-and-authorization-using-ria-services-article-7-of-7/</link>
		<comments>http://peterkellner.net/2010/01/25/authentication-and-authorization-using-ria-services-article-7-of-7/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 23:25:12 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[.NET 4.0]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Entity Framework]]></category>
		<category><![CDATA[RIA Services]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[VS2010]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>
		<category><![CDATA[RIA Service Presentation]]></category>
		<category><![CDATA[RIA Services Bay.Net Presentation]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2010/01/25/authentication-and-authorization-using-ria-services-article-7-of-7/</guid>
		<description><![CDATA[               &#160;       Title Of Each Article       Video Included With Each Post                 Part 1 [...]]]></description>
			<content:encoded><![CDATA[<br /><table width="90%">   <tbody>     <tr>       <td width="70">&nbsp;</td>       <td>Title Of Each Article</td>       <td width="150" style="width: 100px;">Video Included With Each Post</td>     </tr>     <tr>       <td width="70">Part 1</td>       <td><a href="/2010/01/20/riaservices-silverlight-4-tutorial-svcc-part1of7-introduction/">Introduction To RIA Services In Silverlight (This Article)</a></td>       <td width="150" style="width: 100px;">7 Minutes</td>     </tr>     <tr>       <td width="70">Part 2</td>       <td><a href="/2010/01/25/basic-ria-services-and-datagrid-with-vs-2010-tooling-article-2-of-7/">Basic RIA Services And DataGrid With&nbsp; VS 2010 Tooling</a></td>       <td width="150" style="width: 100px;">14 Minutes</td>     </tr>     <tr>       <td width="70">Part 3</td>       <td><a href="/2010/01/23/adding-a-datagrid-with-connect-the-dots-databinding-in-vs-2010-article-3-of-7/">Adding A DataGrid With Connect The Dots DataBinding in VS 2010</a></td>       <td width="150" style="width: 100px;">13 Minutes</td>     </tr>     <tr>       <td width="70">Part 4</td>       <td><a href="/2010/01/25/adding-a-navigation-page-to-a-silverlight-business-application-template-article-4-of-7/">Adding a Navigation Page to a Silverlight Business Application Template</a></td>       <td width="150" style="width: 100px;">11 Minutes</td>     </tr>     <tr>       <td width="70">Part 5</td>       <td><a href="/2010/01/25/adding-speakers-page-template-with-converters-in-visual-studio-2010-beta2-article-5-of-7/">Adding Speakers Page Template With Converters In Visual Studio 2010 Beta2</a></td>       <td width="150" style="width: 100px;">11 Minutes</td>     </tr>     <tr>       <td width="70">Part 6</td>       <td><a href="/2010/01/25/adding-a-sessions-page-that-includes-a-query-parameter-in-silverlight-vs2010-article-6-of-7/">Adding A Sessions Page That Includes a Query Parameter In Silverlight VS2010 Beta2</a></td>       <td width="150" style="width: 100px;">10 Minutes</td>     </tr>     <tr>       <td width="70">Part 7</td>       <td><a href="/2010/01/25/authentication-and-authorization-using-ria-services-article-7-of-7/">Basic Authentication and Authorization In RIA Services</a></td>       <td width="150" style="width: 100px;">5 Minutes</td>     </tr> </tbody></table><br />  <br /><img src="http://video.peterkellner.net/video/RIAServicesBayNet20090120/P7_AuthenticationAndAuthorization_Thumb.jpg" alt="media" /><br />
   <p>This article is very short.&#160; In the actual presentation, there was not much time to talk about this so a brief overview was done.&#160; Basically, it’s all standard WCF stuff.&#160; The idea is that the Silverlight Business Template adds logging in and supports Authentication just like an asp.net application does.&#160; It uses the DomainDataSource to do the bridging between the silverlight clientside app, and the web application.&#160; Authorization is built into the login module also so that you can assign attributes to your domainservice classes to restrict access.</p> <span id="more-484"></span> <p>That is, if you only want people who are logged in able to access one of your methods, you simply tag it as follows with the [RequiresAuthentication] attribute.</p>  <p><a href="http://peterkellner.net/FilesForWebDownload/AuthenticationandAuthorizationUsingRIASe_E1CB/image.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/AuthenticationandAuthorizationUsingRIASe_E1CB/image_thumb.png" width="694" height="222" /></a></p>  <p>If you only want a certain logged in user role to be able to access a certain method, you tag it as follows</p>  <p><a href="http://peterkellner.net/FilesForWebDownload/AuthenticationandAuthorizationUsingRIASe_E1CB/image_3.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/AuthenticationandAuthorizationUsingRIASe_E1CB/image_thumb_3.png" width="710" height="151" /></a></p>  <p>This of course solve the server side only.&#160; On the client side, you need to call methods that are exposed through the domain data.&#160; <a title="http://www.silverlightshow.net/items/Silverlight-3-with-Ria-Authentication-service.aspx" href="http://www.silverlightshow.net/items/Silverlight-3-with-Ria-Authentication-service.aspx">http://www.silverlightshow.net/items/Silverlight-3-with-Ria-Authentication-service.aspx</a> discusses much of this on the client side.</p>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2010/01/25/authentication-and-authorization-using-ria-services-article-7-of-7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<enclosure url="http://video.peterkellner.net/video/RIAServicesBayNet20090120/P7_AuthenticationAndAuthorization.flv" length="1" type="video/x-flv"/>
	</item>
		<item>
		<title>Adding A Sessions Page That Includes a Query Parameter In Silverlight VS2010 Beta2 (Article 6 of 7)</title>
		<link>http://peterkellner.net/2010/01/25/adding-a-sessions-page-that-includes-a-query-parameter-in-silverlight-vs2010-article-6-of-7/</link>
		<comments>http://peterkellner.net/2010/01/25/adding-a-sessions-page-that-includes-a-query-parameter-in-silverlight-vs2010-article-6-of-7/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 23:22:47 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[.NET 4.0]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Entity Framework]]></category>
		<category><![CDATA[LINQ]]></category>
		<category><![CDATA[Presentations]]></category>
		<category><![CDATA[RIA Services]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[VS2010]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2010/01/25/adding-a-sessions-page-that-includes-a-query-parameter-in-silverlight-vs2010-article-6-of-7/</guid>
		<description><![CDATA[&#160;              &#160;        Title Of Each Article        Video Included With Each Post                  [...]]]></description>
			<content:encoded><![CDATA[<p>&#160;</p>  <table width="90%"><tbody>     <tr>       <td width="70">&#160;</td>        <td>Title Of Each Article</td>        <td style="width: 100px" width="150">Video Included With Each Post</td>     </tr>      <tr>       <td width="70">Part 1</td>        <td><a href="/2010/01/20/riaservices-silverlight-4-tutorial-svcc-part1of7-introduction/">Introduction To RIA Services In Silverlight (This Article)</a></td>        <td style="width: 100px" width="150">7 Minutes</td>     </tr>      <tr>       <td width="70">Part 2</td>        <td><a href="/2010/01/25/basic-ria-services-and-datagrid-with-vs-2010-tooling-article-2-of-7/">Basic RIA Services And DataGrid With&#160; VS 2010 Tooling</a></td>        <td style="width: 100px" width="150">14 Minutes</td>     </tr>      <tr>       <td width="70">Part 3</td>        <td><a href="/2010/01/23/adding-a-datagrid-with-connect-the-dots-databinding-in-vs-2010-article-3-of-7/">Adding A DataGrid With Connect The Dots DataBinding in VS 2010</a></td>        <td style="width: 100px" width="150">13 Minutes</td>     </tr>      <tr>       <td width="70">Part 4</td>        <td><a href="/2010/01/25/adding-a-navigation-page-to-a-silverlight-business-application-template-article-4-of-7/">Adding a Navigation Page to a Silverlight Business Application Template</a></td>        <td style="width: 100px" width="150">11 Minutes</td>     </tr>      <tr>       <td width="70">Part 5</td>        <td><a href="/2010/01/25/adding-speakers-page-template-with-converters-in-visual-studio-2010-beta2-article-5-of-7/">Adding Speakers Page Template With Converters In Visual Studio 2010 Beta2</a></td>        <td style="width: 100px" width="150">11 Minutes</td>     </tr>      <tr>       <td width="70">Part 6</td>        <td><a href="/2010/01/25/adding-a-sessions-page-that-includes-a-query-parameter-in-silverlight-vs2010-article-6-of-7/">Adding A Sessions Page That Includes a Query Parameter In Silverlight VS2010 Beta2</a></td>        <td style="width: 100px" width="150">10 Minutes</td>     </tr>      <tr>       <td width="70">Part 7</td>        <td><a href="/2010/01/25/authentication-and-authorization-using-ria-services-article-7-of-7/">Basic Authentication and Authorization In RIA Services</a></td>        <td style="width: 100px" width="150">5 Minutes</td>     </tr>   </tbody></table>  <br />  <br />  <br /><img src="http://video.peterkellner.net/video/RIAServicesBayNet20090120/P6_AddingSessionsPageWithRequestParam_Thumb.jpg" alt="media" /><br />
  <br />  <br />  <p>In this section, we will talk about what happens when the users presses the “Sessions” hyperlink from the speakers page.&#160; If you remember from the last article, we used a special converter on the Speakers.xaml page and bound that to the hyperlink titled sessions as shown below.</p> <span id="more-482"></span>  <p>&#160;</p>  <p><a href="http://peterkellner.net/FilesForWebDownload/AddingASessionsPageThatIncludesaQueryPar_DF36/image.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/AddingASessionsPageThatIncludesaQueryPar_DF36/image_thumb.png" width="376" height="323" /></a></p>  <p>&#160;</p>  <p>When this link is clicked, the navigation created is as follows:</p>  <pre class="csharpcode">&#160;</pre>

<pre class="csharpcode"><a href="http://localhost:9951/Presentation1TestPage.aspx#/Sessions?SpeakerId=903">http://localhost:9951/Presentation1TestPage.aspx#/Sessions?SpeakerId=903</a></pre>

<!-- code formatted by http://manoli.net/csharpformat/ -->
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: Consolas, "Courier New", Courier, Monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}

.csharpcode pre { margin: 0em; }

.csharpcode .rem { color: #008000; }

.csharpcode .kwrd { color: #0000ff; }

.csharpcode .str { color: #006080; }

.csharpcode .op { color: #0000c0; }

.csharpcode .preproc { color: #cc6633; }

.csharpcode .asp { background-color: #ffff00; }

.csharpcode .html { color: #800000; }

.csharpcode .attr { color: #ff0000; }

.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}

.csharpcode .lnum { color: #606060; }
</style>
<div class="csharpcode">
<pre class="alt"><span class="rem">// Executes when the user navigates to this page.</span></pre>
<pre><span class="kwrd">protected</span> <span class="kwrd">override</span> <span class="kwrd">void</span> OnNavigatedTo(NavigationEventArgs e)</pre>
<pre class="alt">{</pre>
<pre>    <span class="rem">//Handle SpeakerId</span></pre>
<pre class="alt">    var qs = NavigationContext.QueryString;</pre>
<pre>    <span class="kwrd">if</span> (qs.ContainsKey(<span class="str">"SpeakerId"</span>))</pre>
<pre class="alt">    {</pre>
<pre>        <span class="kwrd">this</span>.sessionsOverviewDomainDataSource.FilterDescriptors =</pre>
<pre class="alt">            <span class="kwrd">new</span> FilterDescriptorCollection();</pre>
<pre>        <span class="kwrd">this</span>.sessionsOverviewDomainDataSource.FilterDescriptors.Add(</pre>
<pre class="alt">              <span class="kwrd">new</span> FilterDescriptor(<span class="str">"AttendeeId"</span>,</pre>
<pre>                  FilterOperator.IsEqualTo, qs[<span class="str">"SpeakerId"</span>]));</pre>
<pre class="alt">    }</pre>
<pre>}</pre>
</div>

<p>This simply adds a filter to the current DomainDataSource that filters the column AttendeeId with the passed in query parameter SpeakerId.</p>

<p>&#160;</p>

<p>The resulting page looks as follows assuming <a href="http://www.siliconvalley-codecamp.com/Sessions.aspx?ForceSortBySessionTime=true&amp;id=151">Peter Kellner’s Session link</a> was clicked.</p>

<p>&#160;</p>

<p><a href="http://peterkellner.net/FilesForWebDownload/AddingASessionsPageThatIncludesaQueryPar_DF36/image_3.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/AddingASessionsPageThatIncludesaQueryPar_DF36/image_thumb_3.png" width="523" height="207" /></a></p>

<p>&#160;</p>

<p>The video referenced in this article goes into building this page in more details, but fundamentally, the major point is just the query parameter.</p>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2010/01/25/adding-a-sessions-page-that-includes-a-query-parameter-in-silverlight-vs2010-article-6-of-7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<enclosure url="http://video.peterkellner.net/video/RIAServicesBayNet20090120/P6_AddingSessionsPageWithRequestParam.flv" length="1" type="video/x-flv"/>
	</item>
		<item>
		<title>Basic RIA Services And DataGrid With VS 2010 Tooling (Article 2 of 7)</title>
		<link>http://peterkellner.net/2010/01/25/basic-ria-services-and-datagrid-with-vs-2010-tooling-article-2-of-7/</link>
		<comments>http://peterkellner.net/2010/01/25/basic-ria-services-and-datagrid-with-vs-2010-tooling-article-2-of-7/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 22:51:23 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[.NET 4.0]]></category>
		<category><![CDATA[ASP.NET 2.0]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Entity Framework]]></category>
		<category><![CDATA[RIA Services]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2010/01/25/basic-ria-services-and-datagrid-with-vs-2010-tooling-article-2-of-7/</guid>
		<description><![CDATA[              &#160;        Title Of Each Article        Video Included With Each Post                  [...]]]></description>
			<content:encoded><![CDATA[<br />  <table width="90%"><tbody>     <tr>       <td width="70">&#160;</td>        <td>Title Of Each Article</td>        <td style="width: 100px" width="150">Video Included With Each Post</td>     </tr>      <tr>       <td width="70">Part 1</td>        <td><a href="/2010/01/20/riaservices-silverlight-4-tutorial-svcc-part1of7-introduction/">Introduction To RIA Services In Silverlight (This Article)</a></td>        <td style="width: 100px" width="150">7 Minutes</td>     </tr>      <tr>       <td width="70">Part 2</td>        <td><a href="/2010/01/25/basic-ria-services-and-datagrid-with-vs-2010-tooling-article-2-of-7/">Basic RIA Services And DataGrid With&#160; VS 2010 Tooling</a></td>        <td style="width: 100px" width="150">14 Minutes</td>     </tr>      <tr>       <td width="70">Part 3</td>        <td><a href="/2010/01/23/adding-a-datagrid-with-connect-the-dots-databinding-in-vs-2010-article-3-of-7/">Adding A DataGrid With Connect The Dots DataBinding in VS 2010</a></td>        <td style="width: 100px" width="150">13 Minutes</td>     </tr>      <tr>       <td width="70">Part 4</td>        <td><a href="/2010/01/25/adding-a-navigation-page-to-a-silverlight-business-application-template-article-4-of-7/">Adding a Navigation Page to a Silverlight Business Application Template</a></td>        <td style="width: 100px" width="150">11 Minutes</td>     </tr>      <tr>       <td width="70">Part 5</td>        <td><a href="/2010/01/25/adding-speakers-page-template-with-converters-in-visual-studio-2010-beta2-article-5-of-7/">Adding Speakers Page Template With Converters In Visual Studio 2010 Beta2</a></td>        <td style="width: 100px" width="150">11 Minutes</td>     </tr>      <tr>       <td width="70">Part 6</td>        <td><a href="/2010/01/25/adding-a-sessions-page-that-includes-a-query-parameter-in-silverlight-vs2010-article-6-of-7/">Adding A Sessions Page That Includes a Query Parameter In Silverlight VS2010 Beta2</a></td>        <td style="width: 100px" width="150">10 Minutes</td>     </tr>      <tr>       <td width="70">Part 7</td>        <td><a href="/2010/01/25/authentication-and-authorization-using-ria-services-article-7-of-7/">Basic Authentication and Authorization In RIA Services</a></td>        <td style="width: 100px" width="150">5 Minutes</td>     </tr>   </tbody></table>  <br />  <br /><img src="http://video.peterkellner.net/video/RIAServicesBayNet20090120/P2_BasicRIANoTooling_Thumb.jpg" alt="media" /><br />
  <p>&#160;</p>  <p>In this article, we will&#160; build from scratch, using Visual Studio 2010 Beta 2 a simple application that lets us view <a href="http://www.siliconvalley-codecamp.com/">Silicon Valley Code Camp</a> Attendees that have authorized us to share their data.&#160; We will be using no special RIA Services Visual Studio 2010 design tools to do this.&#160; We will:</p>  <ul>   <li>Create the <a href="http://msdn.microsoft.com/en-us/library/aa697427(VS.80).aspx">Entity Framework</a> Repository </li>    <li>Create the Domain Service </li>    <li>Wire up an Appropriate Get Method that Returns in <a href="http://msdn.microsoft.com/en-us/library/system.linq.iqueryable.aspx">IQueryable</a> </li>    <li>Call From the Client Code the Domain Service </li>    <li>Show The Results </li>    <li>Observations </li> </ul>  <p>First, we need to create a new Visual Studio Project.&#160; We do that by using the File/New Project and chose “Silverlight Business Application”.</p> <span id="more-478"></span>  <p><a href="/FilesForWebDownload/BasicRIAWithMinimalVS2010ToolingArticle2_DD97/image.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="/FilesForWebDownload/BasicRIAWithMinimalVS2010ToolingArticle2_DD97/image_thumb.png" width="441" height="246" /></a></p>  <h2>Create The Entity Framework</h2>  <p>Then, we need to create an Entity Framework Repository that will be the target of our Domain Service.&#160; We do that by adding to the web project (not the top, <a href="http://silverlight.net/">Silverlight</a> project), we just created and “ADO.NET Entity Data Model”.&#160; We’ll call it ModelSVCC for Model Silicon Valley Code Camp.</p>  <p><a href="/FilesForWebDownload/BasicRIAWithMinimalVS2010ToolingArticle2_DD97/image_3.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="/FilesForWebDownload/BasicRIAWithMinimalVS2010ToolingArticle2_DD97/image_thumb_3.png" width="456" height="258" /></a></p>  <p>We use the option “Generate From Database” as follows:</p>  <p><a href="/FilesForWebDownload/BasicRIAWithMinimalVS2010ToolingArticle2_DD97/image_4.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="/FilesForWebDownload/BasicRIAWithMinimalVS2010ToolingArticle2_DD97/image_thumb_4.png" width="320" height="284" /></a></p>  <p>Choose the appropriate connection (in our case svcodecamp on our local Sql Server 2008 database).</p>  <p><a href="/FilesForWebDownload/BasicRIAWithMinimalVS2010ToolingArticle2_DD97/image_5.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="/FilesForWebDownload/BasicRIAWithMinimalVS2010ToolingArticle2_DD97/image_thumb_5.png" width="343" height="305" /></a></p>  <p>For simplicity, choose all tables and views as follows.</p>  <p><a href="/FilesForWebDownload/BasicRIAWithMinimalVS2010ToolingArticle2_DD97/image_6.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="/FilesForWebDownload/BasicRIAWithMinimalVS2010ToolingArticle2_DD97/image_thumb_6.png" width="340" height="302" /></a></p>  <p>Do a Rebuild/All to make sure all the template code get’s generated and we are done with our first step.</p>  <h2>Create the Domain Service</h2>  <p>Next, create the Domain Service.&#160; This is done by adding again to the web project the Domain Service as follows.</p>  <p><a href="/FilesForWebDownload/BasicRIAWithMinimalVS2010ToolingArticle2_DD97/image_7.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="/FilesForWebDownload/BasicRIAWithMinimalVS2010ToolingArticle2_DD97/image_thumb_7.png" width="372" height="211" /></a></p>  <p>Name it DomainServiceSVCC.cs again for Silicon Valley Code Camp.</p>  <p>Next check all tables and views, make sure “Enable Client Access” is checked and also “Generate associated classes for meta data”.&#160; Enable Client Access adds an attribute to the generated domain class which tell Visual Studio (on building) to generate the same domain classes on the client (Silverlight) side.&#160; This means that you are writing both your client and server code at the same time!&#160; Very convenient.</p>  <p><a href="/FilesForWebDownload/BasicRIAWithMinimalVS2010ToolingArticle2_DD97/image_8.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="/FilesForWebDownload/BasicRIAWithMinimalVS2010ToolingArticle2_DD97/image_thumb_8.png" width="259" height="316" /></a> <a href="/FilesForWebDownload/BasicRIAWithMinimalVS2010ToolingArticle2_DD97/image_9.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="/FilesForWebDownload/BasicRIAWithMinimalVS2010ToolingArticle2_DD97/image_thumb_9.png" width="354" height="189" /></a></p>  <p>Now, to the method generated in the Domain Service class add an OrderBy Linq command so that the method GetAttendeesWithShare has an implicit order and Skip and Take LINQ will work and the total number of records can be easily obtained (notice the yellow highlighing is the code we added, the rest was there before).</p>  <p><a href="/FilesForWebDownload/BasicRIAWithMinimalVS2010ToolingArticle2_DD97/image_10.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="/FilesForWebDownload/BasicRIAWithMinimalVS2010ToolingArticle2_DD97/image_thumb_10.png" width="623" height="166" /></a></p>  <p>Finally, Rebuild/All again and we are done creating the domain service class for this example.</p>  <h2>Wire up an Appropriate Get Method that Returns in IQueryable</h2>  <p>Now that we have our Domain Service built on the Server side (and of course it get’s exposed on the client side with Visual Studio 2010 template generating magic), we can go to one of the pages built in the default template, add a Silverlight DataGrid and assign our Domain Context to that. Let’s add the list of attendees to our Home Page.&#160; We do that by going to the View\Home.xaml file and simply add a DataGrid tag to the page (see below highlighted in yellow, we simply typed that in or could have dragged it from the toolbar if we are so included).</p>  <p><a href="/FilesForWebDownload/BasicRIAWithMinimalVS2010ToolingArticle2_DD97/image_11.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="/FilesForWebDownload/BasicRIAWithMinimalVS2010ToolingArticle2_DD97/image_thumb_11.png" width="429" height="376" /></a></p>  <p>Then, we go to the code behind of this page and add the following code to the “OnNavigateTo” enent of the Home.xaml page.</p>  <pre class="csharpcode"> var context = <span class="kwrd">new</span> DomainServiceSVCC();
 dataGrid1.ItemsSource = context.AttendeesWithShares;
 context.Load(context.GetAttendeesWithSharesQuery());</pre>

<p>
  <br /></p>
<style type="text/css">







.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p><a href="/FilesForWebDownload/BasicRIAWithMinimalVS2010ToolingArticle2_DD97/image_12.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="/FilesForWebDownload/BasicRIAWithMinimalVS2010ToolingArticle2_DD97/image_thumb_12.png" width="502" height="147" /></a></p>

<p>Now, when we rebuild all and run, we get:</p>

<p><a href="/FilesForWebDownload/BasicRIAWithMinimalVS2010ToolingArticle2_DD97/image_13.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="/FilesForWebDownload/BasicRIAWithMinimalVS2010ToolingArticle2_DD97/image_thumb_13.png" width="317" height="172" /></a></p>

<p>When we click on the Id’s column header, we get the data sorted in reverse Id order, even though we never code an event for that!</p>

<p><a href="/FilesForWebDownload/BasicRIAWithMinimalVS2010ToolingArticle2_DD97/image_14.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="/FilesForWebDownload/BasicRIAWithMinimalVS2010ToolingArticle2_DD97/image_thumb_14.png" width="317" height="172" /></a></p>

<h2>Observations</h2>

<p>So, what have we done?&#160; Well, we’ve done a lot. first, we’ve create a Domain Service that uses WCF on the server side.&#160; We created code on the Silverlight client that called this domain service.&#160; We got databinding right through to our output.&#160; Be very clear that in our code we added to the OnNavigate Event (repeated here)</p>

<p><a href="/FilesForWebDownload/BasicRIAWithMinimalVS2010ToolingArticle2_DD97/image_12.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="/FilesForWebDownload/BasicRIAWithMinimalVS2010ToolingArticle2_DD97/image_thumb_12.png" width="322" height="96" /></a></p>

<p>we made a clear step across the network boundary.&#160; We created the DataService context and when we loaded it, all the async magic just happened for us.&#160; No wsdl’s, proxies to code, keep updated, etc.&#160; All that actually happens for us, but we don’t have to worry about it.&#160; I think I’m in love.</p>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2010/01/25/basic-ria-services-and-datagrid-with-vs-2010-tooling-article-2-of-7/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
	<enclosure url="http://video.peterkellner.net/video/RIAServicesBayNet20090120/P2_BasicRIANoTooling.flv" length="1" type="video/x-flv"/>
	</item>
		<item>
		<title>Introduction To Using RIA Services In Silverlight (Article 1 of 7)</title>
		<link>http://peterkellner.net/2010/01/20/riaservices-silverlight-4-tutorial-svcc-part1of7-introduction/</link>
		<comments>http://peterkellner.net/2010/01/20/riaservices-silverlight-4-tutorial-svcc-part1of7-introduction/#comments</comments>
		<pubDate>Wed, 20 Jan 2010 19:12:09 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[.NET 4.0]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Entity Framework]]></category>
		<category><![CDATA[RIA Services]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Speaking]]></category>
		<category><![CDATA[VS2010]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[XAML]]></category>

		<guid isPermaLink="false">http://peterkellner.net/?p=405</guid>
		<description><![CDATA[This series of video presentations goes through the process of building a Speaker and Sessions Viewer for Silicon Valley Code Camp’s data using Silverlight 4 and RIA Services (Using Visual Studio 2010 Beta 2).&#160; It starts with a brief introduction of RIA Services and is followed by screen casts and blog posts the parallel each [...]]]></description>
			<content:encoded><![CDATA[<p>This series of video presentations goes through the process of building a Speaker and Sessions Viewer for Silicon Valley Code Camp’s data using <a href="http://blogs.msdn.com/brada/">Silverlight 4</a> and <a href="http://silverlight.net/getstarted/riaservices/">RIA Services</a> (Using Visual Studio 2010 Beta 2).&#160; It starts with a brief introduction of RIA Services and is followed by screen casts and blog posts the parallel each screen cast.</p>  <p>The actual <a href="/2010/01/13/baynet-presentation-riaservices/">presentation</a> was done at the Microsoft office in San Francisco. </p> <span id="more-405"></span>  <table width="90%"><tbody>     <tr>       <td width="70">&#160;</td>        <td>Title Of Each Article</td>        <td style="width: 100px" width="150">Video Included With Each Post</td>     </tr>      <tr>       <td width="70">Part 1</td>        <td><a href="/2010/01/20/riaservices-silverlight-4-tutorial-svcc-part1of7-introduction/">Introduction To RIA Services In Silverlight (This Article)</a></td>        <td style="width: 100px" width="150">7 Minutes</td>     </tr>      <tr>       <td width="70">Part 2</td>        <td><a href="/2010/01/25/basic-ria-services-and-datagrid-with-vs-2010-tooling-article-2-of-7/">Basic RIA Services And DataGrid With&#160; VS 2010 Tooling</a></td>        <td style="width: 100px" width="150">14 Minutes</td>     </tr>      <tr>       <td width="70">Part 3</td>        <td><a href="/2010/01/23/adding-a-datagrid-with-connect-the-dots-databinding-in-vs-2010-article-3-of-7/">Adding A DataGrid With Connect The Dots DataBinding in VS 2010</a></td>        <td style="width: 100px" width="150">13 Minutes</td>     </tr>      <tr>       <td width="70">Part 4</td>        <td><a href="/2010/01/25/adding-a-navigation-page-to-a-silverlight-business-application-template-article-4-of-7/">Adding a Navigation Page to a Silverlight Business Application Template</a></td>        <td style="width: 100px" width="150">11 Minutes</td>     </tr>      <tr>       <td width="70">Part 5</td>        <td><a href="/2010/01/25/adding-speakers-page-template-with-converters-in-visual-studio-2010-beta2-article-5-of-7/">Adding Speakers Page Template With Converters In Visual Studio 2010 Beta2</a></td>        <td style="width: 100px" width="150">11 Minutes</td>     </tr>      <tr>       <td width="70">Part 6</td>        <td><a href="/2010/01/25/adding-a-sessions-page-that-includes-a-query-parameter-in-silverlight-vs2010-article-6-of-7/">Adding A Sessions Page That Includes a Query Parameter In Silverlight VS2010 Beta2</a></td>        <td style="width: 100px" width="150">10 Minutes</td>     </tr>      <tr>       <td width="70">Part 7</td>        <td><a href="/2010/01/25/authentication-and-authorization-using-ria-services-article-7-of-7/">Basic Authentication and Authorization In RIA Services</a></td>        <td style="width: 100px" width="150">5 Minutes</td>     </tr>   </tbody></table>  <br />  <br /><img src="http://video.peterkellner.net/video/RIAServicesBayNet20090120/P1_Intro_Thumb.jpg" alt="media" /><br />
  <p>I’ve heavily borrowed from Brad Abrams <a href="http://blogs.msdn.com/brada/archive/2009/11/19/pdc09-talk-building-amazing-business-applications-with-silverlight-4-ria-services-and-visual-studio-2010.aspx">PDC09 presentation</a> here and am very thankful for the help.&#160; I’m personally very excited about the opportunities <a href="http://silverlight.net/getstarted/riaservices/">RIA Services</a> gives us as developers to efficiently build powerful multi tier applications without compromise.</p>  <p>I’d recommend going to Brad Abrams PDC09 presentation mentioned above to get a better understanding of what Microsoft was thinking and its plans for RIA Services. The way I see it is RIA Services is built on the WCF Stack.&#160; It basically is a technology that let’s the developer create both client and server code at the same time.&#160; It essentially removes the middle layer form a development perspective, but keeps it there in a very physical way using all the power of WCF.&#160; For example, you create you logic on the server side and that code automatically gets migrated to the client for simplicity of calling.</p>  <p>For those interested where the motivation came from to to this, it’s an interesting story.&#160; Last week, <a href="http://blog.brandewinder.com/">Mathias Brandewinder</a>, the organizer of our local Bay.Net San Francisco user group emailed and asked if I could fill in last minute for the upcoming (actually today’s) bay.net meeting and, could I talk about RIA Services.&#160; Well, 2 years or so ago, I did a quite extensive Silverlight 1.1 project for Leverage Software using the first beta of the .CLR release of Silverlight (C#).&#160; I have to say, it was an awful experience.&#160; So, now at <a href="http://www.silverlight.net/">Silverlight</a> 4.0, RIA Services, I’m back and very excited. </p>  <p>By way of people that have helped me in the last week to get this far, just to name a few:&#160; <a href="http://blogs.msdn.com/brunoterkaly/default.aspx">Bruno Terkaly</a>, offering to do whatever he could and giving me tech tips, <a href="http://blogs.msdn.com/synergist/">Michael Scherotter</a> in “going to town” as he says to make the Speaker’s page look really nice in a live meeting, <a href="http://victorgaudioso.wordpress.com/">Victor Gaudioso</a> in taking time on his busy weekend to call me&#160; and offer help, <a href="http://blogs.msdn.com/brada/archive/2010/01/17/great-ria-services-overview-in-dr-dobbs.aspx">Brad Abrams</a> putting up with my list of naive questions and patiently responding, a slew of <a href="http://aspinsiders.com/default.aspx">ASPInsiders</a> who pointed me at an excellent place to host the videos, and <a href="http://hackingsilverlight.blogspot.com/">David Kelly</a> for giving me a nicely styled Silverlight player to show the videos on this blog.</p>  <p>I’m sitting in the mall below the <a href="http://www.microsoft.com/about/companyinformation/usaoffices/northwest/sanfrancisco.mspx">Microsoft Office in San Francisco</a> where the presentation will be in about 2 hours.&#160; Hopefully, I’ll finish all seven articles and get them posted to the internet very soon.&#160; I did the videos as just practice for my presentation.&#160; They are not polished or edited.&#160; I’m taking the chance of posting them in the hopes that they help someone struggling with all the new features like I have been during the last week.</p>  <p>Finally, this demo is built on live <a href="http://www.siliconvalley-codecamp.com/">Silicon Valley Code Camp</a> Data that has been collected over the past 4 years.&#160; I can’t really publish that database along with the completed solution before I clean and randomize the attendee data.&#160; Meanwhile, I will post the project code but it will not work until I’ve had a chance to clean up the database.&#160; My thinking is that it’s all positive and better to release the code now rather than wait until I have the database cleaned up.</p>  <p>Below is what the end result of what we are building will look like (if you make it through all the articles and videos).</p>  <p><a href="http://peterkellner.net/FilesForWebDownload/UsingRIAServicesWithVisualStudio2010Beta_94F1/image.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/UsingRIAServicesWithVisualStudio2010Beta_94F1/image_thumb.png" width="414" height="494" /></a></p>  <p>Attached here is source that you can build with Visual Studio 2010 Beta 2 and it will work with No Database.&#160; The Domain Class is heavily modified from what is presented, but it will allow you to actually run and play with real data. </p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:f125b32d-a630-4c3b-838b-1dc56760eeb7" class="wlWriterSmartContent">   <p><a href="/FilesForWebDownload/UsingRIAServicesWithVisualStudio2010Beta_94F1/RIAService_BayNet_NoDatabase.zip" target="_blank">Solution Zip File</a></p> </div>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:8eb9d37f-1541-4f29-b6f4-1eea890d4876:758c6f86-44c4-4139-b6fe-133a4e6f71b4" class="wlWriterSmartContent">   <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:8eb9d37f-1541-4f29-b6f4-1eea890d4876:758c6f86-44c4-4139-b6fe-133a4e6f71b4" class="wlWriterSmartContent"></div>    <p></p> </div>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2010/01/20/riaservices-silverlight-4-tutorial-svcc-part1of7-introduction/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	<enclosure url="http://video.peterkellner.net/video/RIAServicesBayNet20090120/P1_Intro.flv" length="1" type="video/x-flv"/>
	</item>
		<item>
		<title>Book Review &#8211; Programming Entity Framework (EF) by Julie Lerman</title>
		<link>http://peterkellner.net/2009/12/14/programming-entity-framework-bookreview/</link>
		<comments>http://peterkellner.net/2009/12/14/programming-entity-framework-bookreview/#comments</comments>
		<pubDate>Mon, 14 Dec 2009 17:36:53 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[.NET 4.0]]></category>
		<category><![CDATA[Book Reviews]]></category>
		<category><![CDATA[Entity Framework]]></category>
		<category><![CDATA[VS2010]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2009/12/14/programming-entity-framework-bookreview/</guid>
		<description><![CDATA[&#160;  You all know that I’ve blogged quite a bit about LINQ2SQL.&#160; That technology has saved me a huge amount of programming effort verses using ado.net directly.&#160; We all know that LINQ2SQL is really just a stepping stone to Entity Framework (EF), though Microsoft doesn’t quite say that.&#160; I’m sure, based on how many [...]]]></description>
			<content:encoded><![CDATA[<p>&#160;</p>  <p>You all know that I’ve blogged quite a bit about LINQ2SQL.&#160; That technology has saved me a huge amount of programming effort verses using ado.net directly.&#160; We all know that LINQ2SQL is really just a stepping stone to <a href="http://msdn.microsoft.com/en-us/library/aa697427(VS.80).aspx">Entity Framework</a> (EF), though Microsoft doesn’t quite say that.&#160; I’m sure, based on how many people are using LINQ2SQL, it will live on and be supported for quite sometime.&#160; Personally, I’ve been waiting for EF to become more mature and then, I assume I’ll start all my new projects with it (EF) and slowly migrate my old ones from LINQ2SQL to EF.&#160; So, time for me to start taking EF more seriously.&#160; It’s baked into the upcoming <a href="http://www.microsoft.com/net/">.net</a> 4.0 and <a href="http://www.microsoft.com/visualstudio/en-us/products/2010/default.mspx">Visual Studio 2010</a> beta 2.&#160; It’s obviously not done, but from what I’ve seen, when .net 4.0 releases, EF will be ready for prime time.</p>  <p>Now, for the review:</p> <span id="more-396"></span>  <p><a href="http://thedatafarm.com/blog/">Julie</a> does a great job of introducing Entity Framework and explaining where it fits in, and why you should consider using it.&#160; I was already sold, but now I understand better why.&#160; She then does an excellent job of going through the basics of EF, telling you how to use it, describing the model and all the details necessary to begin using it.&#160; One of the nice features of this book, is it goes beyond the theoretical, and talks about specific implementations.&#160; That is, WCF, WPF, etc.</p>  <p>We all need to get more comfortable with EF and this book is a great starting place.&#160; <a href="http://thedatafarm.com/blog/">Julie Lerman</a> is clearly the person to learn this from.&#160; I strongly recommend it.</p>  <p>&#160;</p>  <table border="0" cellspacing="0" cellpadding="0"><tbody>     <tr>       <td><img src="http://ecx.images-amazon.com/images/I/41inTvXhKKL._SL75_.jpg" /> </td>        <td valign="top"><a href="http://www.amazon.com/Programming-Entity-Framework-Julia-Lerman/dp/059652028X%3FSubscriptionId%3D0JTCV5ZMHMF7ZYTXGFR2%26tag%3Dpetkelsblo-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D059652028X">Programming Entity Framework</a> </td>     </tr>   </tbody></table>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2009/12/14/programming-entity-framework-bookreview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced)
Database Caching 4/19 queries in 0.003 seconds using disk

Served from: peterkellner.net @ 2012-02-10 04:49:36 -->
