<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Jaroslaw Kowalski</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/jkowalski/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/jkowalski/feed.xml</link>
    <description />
    <lastBuildDate>Wed, 17 Apr 2019 03:21:08 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Migrating from EF POCO Adapter to Entity Framework v4.0</title>
      <link>https://docs.microsoft.com/archive/blogs/jkowalski/migrating-from-ef-poco-adapter-to-entity-framework-v4-0</link>
      <pubDate>Wed, 14 Apr 2010 10:13:00 GMT</pubDate>
      <dc:creator><![CDATA[Jaroslaw Kowalski - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jkowalski/2010/04/14/migrating-from-ef-poco-adapter-to-entity-framework-v4-0/</guid>
      <description><![CDATA[Now that Visual Studio 2010 and .NET Framework 4.0 have been released, users of Entity Framework can...]]></description>
      <content:encoded><![CDATA[<P>Now that Visual Studio 2010 and .NET Framework 4.0 have been released, users of Entity Framework can use POCO objects with Entity Framework without the need for wrapper layers such as <A onclick="javascript:pageTracker._trackPageview('/outbound/article/https://code.msdn.com/EFPocoAdapter');" href="https://code.msdn.com/EFPocoAdapter"><FONT color=#2d83d5>EFPocoAdapter</FONT></A>. Since I know a number of people are using EFPocoAdapter in their production applications and it is not supported, I recommend they migrate to using native POCO support in EF v4.0 which is the supported way of using POCOs from now on. </P>
<P>This post will highlight the differences between EF and EFPOCOAdapter, which you must keep in mind when migrating your code base. </P>
<P><A title="Migrating from EF POCO Adapter to Entity Framework v4.0" href="https://jkowalski.com/2010/04/14/migrating-from-ef-poco-adapter-to-entity-framework-v4-0/" mce_href="https://jkowalski.com/2010/04/14/migrating-from-ef-poco-adapter-to-entity-framework-v4-0/">[Read more]</A></P>]]></content:encoded>
    </item>
    <item>
      <title>Blog migrated to a new domain</title>
      <link>https://docs.microsoft.com/archive/blogs/jkowalski/blog-migrated-to-a-new-domain</link>
      <pubDate>Wed, 14 Apr 2010 09:54:00 GMT</pubDate>
      <dc:creator><![CDATA[Jaroslaw Kowalski - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jkowalski/2010/04/14/blog-migrated-to-a-new-domain/</guid>
      <description><![CDATA[I’ve migrated my blog to a new domain: https://jkowalski.com&nbsp;- please update your links and RSS...]]></description>
      <content:encoded><![CDATA[<P>I’ve migrated my blog to a new domain: <A href="https://jkowalski.com/" mce_href="https://jkowalski.com/">https://jkowalski.com</A>&nbsp;- please update your links and RSS subscriptions.</P>
<P>In order not to duplicate content, but preserve the history I’ve created stub posts which link back to original content here and recreated tag structure&nbsp;for easier navigation within the new site. All migrated posts are tagged as <A href="https://jkowalski.com/tag/migrated-post/" mce_href="https://jkowalski.com/tag/migrated-post/"><FONT color=#2d83d5>Migrated Post</FONT></A>&nbsp;for easy identification.</P>
<P mce_keep="true">&nbsp;</P>]]></content:encoded>
    </item>
    <item>
      <title>Using EFProviderWrappers with precompiled views</title>
      <link>https://docs.microsoft.com/archive/blogs/jkowalski/using-efproviderwrappers-with-precompiled-views</link>
      <pubDate>Mon, 15 Jun 2009 12:06:54 GMT</pubDate>
      <dc:creator><![CDATA[Jaroslaw Kowalski - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jkowalski/2009/06/15/using-efproviderwrappers-with-precompiled-views/</guid>
      <description><![CDATA[One of the users has reported a problem with using EFProviderWrappers and precompiled views...]]></description>
      <content:encoded><![CDATA[<p>One of the users has reported a problem with using <a href="https://code.msdn.com/EFProviderWrappers">EFProviderWrappers</a> and precompiled views together.</p>  <p>When you pre-compile views, Entity Framework calculates a hash of metadata (which includes csdl,ssdl and msl information), stores it with the generated views and compares it later when metadata is loaded. When loaded metadata doesn’t match the hash stored in pre-compiled views, an exception is thrown.</p>  <p>Injecting a provider into provider chains involves changing SSDL file and that invalidates the hash.</p>  <p>Fortunately there’s a workaround, which enables you to use pre-compiled views and wrapper providers together, but you have to use the <a href="https://blogs.msdn.com/jkowalski/archive/2009/06/11/tracing-and-caching-in-entity-framework-available-on-msdn-code-gallery.aspx#alternativeinjection">Alternative injection method as described in original blog post</a>.</p>  <p>Let’s assume you have followed the steps outlined in the post and have your modified SSDL file ready. Injecting is a bit tricky because of additional registration required for EdmGen.exe to work. The first part involves creating a modified version of EdmGen.exe which can handle wrapper providers:</p>  <ol>   <li>Create a working directory (say “<strong>C:\ViewGeneration</strong>”) </li>    <li>Copy <strong>%WINDIR%\Microsoft.NET\Framework\v3.5\EdmGen.exe</strong> and <strong>%WINDIR%\Microsoft.NET\Framework\v3.5\EdmGen.exe.config</strong> to that directory </li>    <li>Open <strong>C:\ViewGeneration\EdmGen.exe.config</strong> using notepad </li>    <li>Add Provider Registration section before the end of the configuration file so that it looks like this:      <pre class="csharpcode"><span class="kwrd">&lt;?</span><span class="html">xml</span> <span class="attr">version</span><span class="kwrd">=&quot;1.0&quot;</span> <span class="attr">encoding</span><span class="kwrd">=&quot;utf-8&quot;</span> ?<span class="kwrd">&gt;</span>
<span class="kwrd">&lt;</span><span class="html">configuration</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;</span><span class="html">runtime</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">generatePublisherEvidence</span> <span class="attr">enabled</span><span class="kwrd">=&quot;false&quot;</span><span class="kwrd">/&gt;</span>
  <span class="kwrd">&lt;/</span><span class="html">runtime</span><span class="kwrd">&gt;</span>
  <span class="rem">&lt;!-- declare provider factories --&gt;</span>
  <span class="kwrd">&lt;</span><span class="html">system.data</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">DbProviderFactories</span><span class="kwrd">&gt;</span>
      <span class="kwrd">&lt;</span><span class="html">add</span> <span class="attr">name</span><span class="kwrd">=&quot;EF Caching Data Provider&quot;</span>
           <span class="attr">invariant</span><span class="kwrd">=&quot;EFCachingProvider&quot;</span>
           <span class="attr">description</span><span class="kwrd">=&quot;Caching Provider Wrapper&quot;</span>
           <span class="attr">type</span><span class="kwrd">=&quot;EFCachingProvider.EFCachingProviderFactory, EFCachingProvider, Version=1.0.0.0, Culture=neutral, PublicKeyToken=def642f226e0e59b&quot;</span> <span class="kwrd">/&gt;</span>
      <span class="kwrd">&lt;</span><span class="html">add</span> <span class="attr">name</span><span class="kwrd">=&quot;EF Tracing Data Provider&quot;</span>
           <span class="attr">invariant</span><span class="kwrd">=&quot;EFTracingProvider&quot;</span>
           <span class="attr">description</span><span class="kwrd">=&quot;Tracing Provider Wrapper&quot;</span>
           <span class="attr">type</span><span class="kwrd">=&quot;EFTracingProvider.EFTracingProviderFactory, EFTracingProvider, Version=1.0.0.0, Culture=neutral, PublicKeyToken=def642f226e0e59b&quot;</span> <span class="kwrd">/&gt;</span>
      <span class="kwrd">&lt;</span><span class="html">add</span> <span class="attr">name</span><span class="kwrd">=&quot;EF Generic Provider Wrapper&quot;</span>
           <span class="attr">invariant</span><span class="kwrd">=&quot;EFProviderWrapper&quot;</span>
           <span class="attr">description</span><span class="kwrd">=&quot;Generic Provider Wrapper&quot;</span>
           <span class="attr">type</span><span class="kwrd">=&quot;EFProviderWrapperToolkit.EFProviderWrapperFactory, EFProviderWrapperToolkit, Version=1.0.0.0, Culture=neutral, PublicKeyToken=def642f226e0e59b&quot;</span> <span class="kwrd">/&gt;</span>
    <span class="kwrd">&lt;/</span><span class="html">DbProviderFactories</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;/</span><span class="html">system.data</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">configuration</span><span class="kwrd">&gt;</span></pre>
  </li>

  <li>Copy <strong>EFTracingProvider.dll, EFCachingProvider.dll</strong> and <strong>EFProviderWrapperToolkit.dll</strong> to <strong>C:\ViewGeneration</strong> </li>
</ol>

<p>(Alternatively you can just gac all the providers and put provider registration section in machine.config, but I think the described method is cleaner as it has only local impact and doesn’t require you to be an administrator).</p>

<p>Once you have the modified EdmGen.exe, you can use it for your view generation as usual, except that you pass modified ssdl file as an argument to /inssdl parameter.</p>

<pre class="csharpcode">C:\ViewGeneration\EdmGen.exe 
    /mode:viewgeneration 
    /incsdl:NorthwindEFModel.csdl 
    /inssdl:NorthwindEFModel.WithTracing.ssdl 
    /inmsl:NorthwindEFModel.msl 
    /outviews:NorthwindEF.views.cs</pre>

<p>This should create you NorthwindEF.views.cs which you can compile along with the rest of your application to get better startup performance.</p>

<p>Now, one more cool trick:</p>

<p>Wrapper-enabled EdmGen.exe can be used not just for view generation. For example it is possible to automatically generate a model from a database using EFTracingProvider! (this will create SSDL file which takes advantage of tracing automatically).</p>

<pre class="csharpcode">C:\ViewGeneration\EdmGen.exe 
    /mode:FullGeneration
    /provider:EFTracingProvider
    /connectionString:<span class="str">&quot;wrappedProvider=System.Data.SqlClient;server=.\SQLEXPRESS;database=NorthwindEF;integrated security=sspi&quot;</span> /project:NW</pre>

<p>You can even use tracing provider <u>during</u> reverse-engineering process, to see what SQL statements are executed. All you need to do is add this section to <strong>C:\ViewGeneration\EdmGen.exe.config</strong>:</p>

<pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">appSettings</span><span class="kwrd">&gt;</span>
  <span class="rem">&lt;!-- this setting causes all log messages to be written to the console. --&gt;</span>
  <span class="kwrd">&lt;</span><span class="html">add</span> <span class="attr">key</span><span class="kwrd">=&quot;EFTracingProvider.logToConsole&quot;</span> <span class="attr">value</span><span class="kwrd">=&quot;true&quot;</span> <span class="kwrd">/&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">appSettings</span><span class="kwrd">&gt;</span></pre>

<p>Enjoy!</p>]]></content:encoded>
    </item>
    <item>
      <title>Tracing and Caching for Entity Framework available on MSDN Code Gallery</title>
      <link>https://docs.microsoft.com/archive/blogs/jkowalski/tracing-and-caching-for-entity-framework-available-on-msdn-code-gallery</link>
      <pubDate>Thu, 11 Jun 2009 13:29:00 GMT</pubDate>
      <dc:creator><![CDATA[Jaroslaw Kowalski - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jkowalski/2009/06/11/tracing-and-caching-for-entity-framework-available-on-msdn-code-gallery/</guid>
      <description><![CDATA[We have just released a sample that shows how to extend Entity Framework in interesting ways by...]]></description>
      <content:encoded><![CDATA[<P>We have just <A href="https://code.msdn.com/EFProviderWrappers" mce_href="https://code.msdn.com/EFProviderWrappers">released a sample</A> that shows how to extend Entity Framework in interesting ways by plugging into ADO.NET provider interface. The sample provides two extensions:</P>
<UL>
<LI>
<DIV><STRONG>EFTracingProvider</STRONG> – which adds the ability to log all SQL commands that are executed (similar to LINQ to SQL’s DataContext.Log</DIV></LI>
<LI>
<DIV><STRONG>EFCachingProvider</STRONG> – which adds transparent query results cache to EF </DIV></LI></UL>
<P>The sample comes with implementation of distributed cache which uses <A href="https://blogs.msdn.com/velocity/archive/2009/04/08/announcing-velocity-ctp3.aspx" mce_href="https://blogs.msdn.com/velocity/archive/2009/04/08/announcing-velocity-ctp3.aspx">Velocity CTP 3</A> as well as an adapter for ASP.NET and simple in-memory cache implementation.</P>
<P><SPAN>Because the sample is quite large and uses many advanced techniques, it’s impossible to fully explain it all in one blog post. In this first post I’ll briefly explain the idea of wrapper providers and describe the new the APIs exposed by EFTracingProvider and EFCachingProvider. In future posts I’ll try to explain more technical detail details and provide advanced logging/caching tips.</SPAN></P>
<H3>Provider Wrapers</H3>
<P>Entity Framework has a public provider model which makes it possible for provider writers to support 3<SUP>rd</SUP>-party databases, such as Oracle, MySQL, PostreSQL, Firebird. The provider model provides uniform way for EF to query the capabilities of the database and execute queries and updates using canonical query tree representation (as opposed to textual queries).</P>
<P>Whenever you issue a LINQ or Entity SQL query through an ObjectContext instance, the query passes through a series of layers (see the picture below). At high level we can say that all queries and updates from ObjectContext are translated and executed through EntityConnection, which in turns talks to server-specific data provider such as SqlClient or Sql Server CE client. </P>
<P>Provider interface used by Entity Framework is stackable, which means it’s possible to write a provider which will wrap another provider and intercept communication between Entity Framework and the original provider. </P>
<P>The wrapper provider gets a chance do interesting things, such as:</P>
<UL>
<LI>Examining query trees and commands before they are executed </LI>
<LI>Controlling connections, commands, transactions, data readers, etc. </LI></UL>
<P><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="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/jkowalski/WindowsLiveWriter/TracingandCachinginEntityFrameworkavaila_860F/image_3.png" original-url="https://blogs.msdn.com/blogfiles/jkowalski/WindowsLiveWriter/TracingandCachinginEntityFrameworkavaila_860F/image_3.png" width=528 height=408 mce_src="https://blogs.msdn.com/blogfiles/jkowalski/WindowsLiveWriter/TracingandCachinginEntityFrameworkavaila_860F/image_3.png"> </P>
<P><STRONG>EFTracingProvider</STRONG> intercepts DbCommand.ExecuteReader(), ExecuteScalar() and ExecuteNonQuery() and sends details about the command (including command text and parameters) to configured outputs.</P>
<P><STRONG>EFCachingProvider</STRONG> is a bit more complex. It uses external caching implementation and caches results of all queries queries that are executed in DbCommand.ExecuteReader(). Whenever update is detected (either UPDATE, INSERT or DELETE) the provider invalidates affected cache entries by evicting all cached queries which were dependent on any of the updated tables.</P>
<H3>Using the sample code</H3>
<P>Here’s a step-by-step guide to downloading and using the sample code in your project:</P>
<OL>
<LI>Download the sample project from MSDN Code Gallery and built it. </LI>
<LI>Take <B>EFCachingProvider.dll</B>, <B>EFTracingProvider.dll</B> and <B>EFProviderWrapperToolkit.dll</B> and place them in a common directory for easy referencing. </LI>
<LI>Add reference to those three assemblies in your application. </LI>
<LI>Register the providers – either: 
<OL>
<LI>Locally for your application (recommended) – put registration entries in App.config (see Provider Registration section below) and make sure that provider DLLs are in your application directory (adding reference and building should take care of that). </LI>
<LI>Globally: GAC the providers and add required registration entries (see Provider Registration section below) to machine.config </LI></OL></LI>
<LI>Copy <B>EFProviderWrapperDemo\ExtendedNorthwindEntities.cs</B> from the sample and put it in your project – rename the class as appropriate – you will need to use this class instead of a regular strongly typed object context class. </LI>
<LI>Modify the base class by replacing NorthwindEntities with the name of your strongly typed object context class. </LI>
<LI>Modify the default constructor by providing your own connection string. </LI>
<LI>(optional) You can also modify the second constructor by specifying which wrapper providers to use. </LI></OL>
<P>That’s it. </P>
<H3>Caching and Tracing APIs</H3>
<P>By using <B>ExtendedNorthwindEntities</B> which was created in previous step, instead of <B>NorthwindEntities</B> you get access to new APIs which control caching and tracing:</P><PRE class=csharpcode><SPAN class=kwrd>public</SPAN> TextWriter Log { get; set; }</PRE>
<P>Specifies the text writer where log output should be written - same as in LINQ to SQL </P><PRE class=csharpcode><SPAN class=kwrd>public</SPAN> ICache Cache { get; set; }</PRE>
<P>Specifies which cache should be used for the context (typically a global one). The sample comes with 3 implementations of ICache interface which you can be used in your applications:</P>
<UL>
<LI>AspNetCache – cache which uses ASP.NET caching mechanism </LI>
<LI>InMemoryCache – simple, in-memory cache with basic LRU expiration policy </LI>
<LI>VelocityCache – implementation of caching which uses Microsoft Distributed Cache codename "Velocity" CTP3. </LI></UL><PRE class=csharpcode><SPAN class=kwrd>public</SPAN> CachingPolicy CachingPolicy { get; set; }</PRE>
<P>Specifies caching policy. There are 3 policies included in the package:</P>
<UL>
<LI>CachingPolicy.CacheAll – caches all queries regardless of their results size or affected tables </LI>
<LI>CachingPolicy.NoCaching – disables caching </LI>
<LI>CustomCachingPolicy – includes user-configurable list of tables that should and should not be cached, as well as expiration times and result size limits. </LI></UL>
<P>It is also possible to write your own caching policy by creating a class which derives from CachingPolicy and overriding a bunch of methods.</P>
<P>For more advanced logging scenarios there are also 3 events, which provide access to raw DbCommand objects and some additional information:</P><PRE class=csharpcode><SPAN class=kwrd>public</SPAN> <SPAN class=kwrd>event</SPAN> EventHandler&lt;CommandExecutionEventArgs&gt; CommandExecuting
<SPAN class=kwrd>public</SPAN> <SPAN class=kwrd>event</SPAN> EventHandler&lt;CommandExecutionEventArgs&gt; CommandFinished
<SPAN class=kwrd>public</SPAN> <SPAN class=kwrd>event</SPAN> EventHandler&lt;CommandExecutionEventArgs&gt; CommandFailed</PRE>
<P>The events are raised before and after each command is executed. </P>
<H3>Global configuration</H3>
<P>You can also configure logging defaults through static properties of EFTracingProviderConfiguration class and they will apply to all new contexts:</P><PRE class=csharpcode><SPAN class=kwrd>public</SPAN> <SPAN class=kwrd>static</SPAN> <SPAN class=kwrd>bool</SPAN> LogToConsole { get; set; }</PRE>
<P>Specifies whether every SQL command should be logged to the console. </P><PRE class=csharpcode><SPAN class=kwrd>public</SPAN> <SPAN class=kwrd>static</SPAN> <SPAN class=kwrd>string</SPAN> LogToFile { get; set; }</PRE>
<P>Specifies global log file. </P><PRE class=csharpcode><SPAN class=kwrd>public</SPAN> <SPAN class=kwrd>static</SPAN> Action&lt;CommandExecutionEventArgs&gt; LogAction { get; set; }</PRE>
<P>Specifies global custom logging action – a delegate that will be invoked before and after each command is executed.</P>
<H3>Tracing Example</H3>
<P>In order to write all SQL commands to a file, you must create a text writer object to write to and assign it to context.Log:</P><FONT size=2 face=Consolas><FONT size=2 face=Consolas><PRE class=csharpcode><SPAN class=kwrd>using</SPAN> (TextWriter logFile = File.CreateText(<SPAN class=str>"sqllogfile.txt"</SPAN>))
{
  <SPAN class=kwrd>using</SPAN> (var context = <SPAN class=kwrd>new</SPAN> ExtendedNorthwindEntities())
  {
    context.Log = logFile;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN class=rem>// ... </SPAN>
  }
}</PRE></FONT></FONT>
<P>Logging to the console is even easier:</P><PRE class=csharpcode><SPAN class=kwrd>using</SPAN> (var context = <SPAN class=kwrd>new</SPAN> ExtendedNorthwindEntities())
{
  context.Log = Console.Out;&nbsp;&nbsp; <SPAN class=rem>// ... </SPAN>
}</PRE>
<P>More advanced logging can be achieved by hooking up Command*events:</P><FONT size=2 face=Consolas><FONT size=2 face=Consolas><PRE class=csharpcode><SPAN class=kwrd>using</SPAN> (var context = <SPAN class=kwrd>new</SPAN> ExtendedNorthwindEntities())
{
  context.CommandExecuting += (sender, e) =&gt;
  {
   Console.WriteLine(<SPAN class=str>"Command is executing: {0}"</SPAN>, e.ToTraceString());
  };
  context.CommandFinished += (sender, e) =&gt;
  {
    Console.WriteLine(<SPAN class=str>"Command has finished: {0}"</SPAN>, e.ToTraceString());
  };&nbsp;&nbsp; <SPAN class=rem>// ... </SPAN>
}</PRE></FONT></FONT>
<P>To enable tracing globally for all connections (to both console and a log file):</P><FONT size=2 face=Consolas><FONT size=2 face=Consolas><PRE class=csharpcode>EFTracingProviderConfiguration.LogToConsole = <SPAN class=kwrd>true</SPAN>;
EFTracingProviderConfiguration.LogToFile = <SPAN class=str>"MyLogFile.txt"</SPAN></PRE></FONT></FONT>
<P><FONT size=2 face=Consolas><FONT size=2 face=Consolas></FONT></FONT></P><FONT size=2 face=Consolas><FONT size=2 face=Consolas></FONT></FONT>
<H3>
<H3>Caching Example</H3></H3>
<P>In order to use caching using InMemoryCache implementation, you must create global instances of your cache and caching policy objects:</P><PRE class=csharpcode>ICache cache = <SPAN class=kwrd>new</SPAN> InMemoryCache(); 
CachingPolicy cachingPolicy = CachingPolicy.CacheAll;</PRE>
<P>In order to use caching with Velocity CTP3, you must create DataCache object and pass it to VelocityCache constructor.</P><PRE class=csharpcode><SPAN class=kwrd>private</SPAN> <SPAN class=kwrd>static</SPAN> ICache CreateVelocityCache(<SPAN class=kwrd>bool</SPAN> useLocalCache)
{
  DataCacheServerEndpoint endpoint = <SPAN class=kwrd>new</SPAN> DataCacheServerEndpoint(<SPAN class=str>"localhost"</SPAN>, 22233, <SPAN class=str>"DistributedCacheService"</SPAN>);
  DataCacheFactory fac = <SPAN class=kwrd>new</SPAN> DataCacheFactory(<SPAN class=kwrd>new</SPAN> DataCacheServerEndpoint[] { endpoint }, useLocalCache, useLocalCache);

  <SPAN class=kwrd>return</SPAN> <SPAN class=kwrd>new</SPAN> VelocityCache(fac.GetCache(<SPAN class=str>"Velocity"</SPAN>));
}</PRE>
<P>Now in order to use either of the caches we need to set up Cache and CachingPolicy properties on the context:</P><PRE class=csharpcode><SPAN class=kwrd>using</SPAN> (var context = <SPAN class=kwrd>new</SPAN> ExtendedNorthwindEntities())
{
  <SPAN class=rem>// set up caching</SPAN>
  context.Cache = cache;
  context.CachingPolicy = cachingPolicy;&nbsp;&nbsp; <SPAN class=rem>// ... </SPAN>
}</PRE>
<H3>Configuring Providers</H3>
<H5>Provider Registration</H5>
<P>Before a provider can work with Entity Framework it must be registered, either in machine.config file or in application configuration file. Configuration for each provider specifies the factory class and gives it three names, two of which are human-readable name and one - provider invariant name is used to refer to the provider in the connection string and SSDL.</P>
<P>Configuration for the providers included in the sample looks like this:</P><PRE class=csharpcode><SPAN class=kwrd>&lt;</SPAN><SPAN class=html>system.data</SPAN><SPAN class=kwrd>&gt;</SPAN>
  <SPAN class=kwrd>&lt;</SPAN><SPAN class=html>DbProviderFactories</SPAN><SPAN class=kwrd>&gt;</SPAN>
    <SPAN class=kwrd>&lt;</SPAN><SPAN class=html>add</SPAN> <SPAN class=attr>name</SPAN><SPAN class=kwrd>="EF Caching Data Provider"</SPAN>
         <SPAN class=attr>invariant</SPAN><SPAN class=kwrd>="EFCachingProvider"</SPAN>
         <SPAN class=attr>description</SPAN><SPAN class=kwrd>="Caching Provider Wrapper"</SPAN>
         <SPAN class=attr>type</SPAN><SPAN class=kwrd>="EFCachingProvider.EFCachingProviderFactory, EFCachingProvider, Version=1.0.0.0, Culture=neutral, PublicKeyToken=def642f226e0e59b"</SPAN> <SPAN class=kwrd>/&gt;</SPAN>
    <SPAN class=kwrd>&lt;</SPAN><SPAN class=html>add</SPAN> <SPAN class=attr>name</SPAN><SPAN class=kwrd>="EF Tracing Data Provider"</SPAN>
         <SPAN class=attr>invariant</SPAN><SPAN class=kwrd>="EFTracingProvider"</SPAN>
         <SPAN class=attr>description</SPAN><SPAN class=kwrd>="Tracing Provider Wrapper"</SPAN>
         <SPAN class=attr>type</SPAN><SPAN class=kwrd>="EFTracingProvider.EFTracingProviderFactory, EFTracingProvider, Version=1.0.0.0, Culture=neutral, PublicKeyToken=def642f226e0e59b"</SPAN> <SPAN class=kwrd>/&gt;</SPAN>
    <SPAN class=kwrd>&lt;</SPAN><SPAN class=html>add</SPAN> <SPAN class=attr>name</SPAN><SPAN class=kwrd>="EF Generic Provider Wrapper"</SPAN>
         <SPAN class=attr>invariant</SPAN><SPAN class=kwrd>="EFProviderWrapper"</SPAN>
         <SPAN class=attr>description</SPAN><SPAN class=kwrd>="Generic Provider Wrapper"</SPAN>
         <SPAN class=attr>type</SPAN><SPAN class=kwrd>="EFProviderWrapperToolkit.EFProviderWrapperFactory, EFProviderWrapperToolkit, Version=1.0.0.0, Culture=neutral, PublicKeyToken=def642f226e0e59b"</SPAN> <SPAN class=kwrd>/&gt;</SPAN>
  <SPAN class=kwrd>&lt;/</SPAN><SPAN class=html>DbProviderFactories</SPAN><SPAN class=kwrd>&gt;</SPAN>
<SPAN class=kwrd>&lt;/</SPAN><SPAN class=html>system.data</SPAN><SPAN class=kwrd>&gt;</SPAN></PRE>
<P mce_keep="true">&nbsp;</P>
<P>This XML fragment can be copied/pasted into any project which needs to use EF provider wrappers or put in the machine.config to be shared by all applications.</P>
<H3>Injecting into provider chain</H3>
<P>In order to inject the provider into the provider chain, you have to modify SSDL files for your project as well as the connection string. There are two ways to do so: automated (which requires application code changes) or manual which can be done externally just by changing configuration file and SSDL file.</P>
<P>In order to create an EntityConnection with injected wrapped providers, you can use the provided helper method:</P><PRE class=csharpcode>connection = EntityConnectionWrapperUtils.CreateEntityConnectionWithWrappers(
  connectionString, <SPAN class=str>"EFTracingProvider"</SPAN>, <SPAN class=str>"EFCachingProvider"</SPAN>)</PRE>
<P>You can then pass <STRONG>connection</STRONG> to ObjectContext constructor or use the connection to run ESQL queries as usual. </P><A title=alternativeinjection name=alternativeinjection></A>
<H3>Alternative injection method</H3>
<P>If you cannot change the application code, you have to make the modifications manually, which involves changing SSDL file and the connection string. Let’s take a quick look to see what SSDL and connection string look like today: The provider name is specified in the Provider attribute of the &lt;Schema/&gt; element:</P><PRE class=csharpcode><SPAN class=kwrd>&lt;</SPAN><SPAN class=html>Schema</SPAN> <SPAN class=attr>Namespace</SPAN><SPAN class=kwrd>="NorthwindEFModel.Store"</SPAN>
  <SPAN class=attr>Alias</SPAN><SPAN class=kwrd>="Self"</SPAN>
  <SPAN class=attr>Provider</SPAN><SPAN class=kwrd>="<U><STRONG><FONT size=3>System.Data.SqlClient</FONT></STRONG></U>"</SPAN>
  <SPAN class=attr>ProviderManifestToken</SPAN><SPAN class=kwrd>="<STRONG><U><FONT size=3>2005</FONT></U></STRONG>"</SPAN>
  <SPAN class=attr>xmlns</SPAN><SPAN class=kwrd>="https://schemas.microsoft.com/ado/2006/04/edm/ssdl"</SPAN><SPAN class=kwrd>&gt;</SPAN></PRE>
<P>Provider invariant name is also be specified in the connection string:</P><PRE class=csharpcode><SPAN class=kwrd>&lt;</SPAN><SPAN class=html>connectionStrings</SPAN><SPAN class=kwrd>&gt;</SPAN>
  <SPAN class=kwrd>&lt;</SPAN><SPAN class=html>add</SPAN> <SPAN class=attr>name</SPAN><SPAN class=kwrd>="NorthwindEntities"</SPAN>
       <SPAN class=attr>connectionString</SPAN><SPAN class=kwrd>="metadata=NorthwindEFModel.csdl | NorthwindEFModel.msl | NorthwindEFModel.ssdl;
                         provider=<STRONG><U><FONT size=3>System.Data.SqlClient</FONT></U></STRONG>; 
                         provider connection string=&amp;quot;Data Source=.\sqlexpress;
Initial Catalog=NorthwindEF;Integrated Security=True;MultipleActiveResultSets=True&amp;quot;"</SPAN>
       <SPAN class=attr>providerName</SPAN><SPAN class=kwrd>="System.Data.EntityClient"</SPAN> <SPAN class=kwrd>/&gt;</SPAN>
<SPAN class=kwrd>&lt;/</SPAN><SPAN class=html>connectionStrings</SPAN><SPAN class=kwrd>&gt;</SPAN></PRE>
<P>In order to inject our own provider we need to override those to point to our provider. In SSDL, we put the name of the new provider in the Provider attribute and concatenate the previous provider with its provider manifest token in the ProviderManifestToken field, like this:</P><PRE class=csharpcode><SPAN class=kwrd>&lt;?</SPAN><SPAN class=html>xml</SPAN> <SPAN class=attr>version</SPAN><SPAN class=kwrd>="1.0"</SPAN> <SPAN class=attr>encoding</SPAN><SPAN class=kwrd>="utf-8"</SPAN>?<SPAN class=kwrd>&gt;</SPAN>
<SPAN class=kwrd>&lt;</SPAN><SPAN class=html>Schema</SPAN> <SPAN class=attr>Namespace</SPAN><SPAN class=kwrd>="NorthwindEFModel.Store"</SPAN>
  <SPAN class=attr>Alias</SPAN><SPAN class=kwrd>="Self"</SPAN>
  <SPAN class=attr>Provider</SPAN><SPAN class=kwrd>="<STRONG><FONT size=3><U>EFCachingProvider</U></FONT></STRONG>"</SPAN>
  <SPAN class=attr>ProviderManifestToken</SPAN><SPAN class=kwrd>="<STRONG><U><FONT size=3>System.Data.SqlClient;2005</FONT></U></STRONG>"</SPAN>
  <SPAN class=attr>xmlns</SPAN><SPAN class=kwrd>="https://schemas.microsoft.com/ado/2006/04/edm/ssdl"</SPAN><SPAN class=kwrd>&gt;</SPAN></PRE>
<P>Modifying connection string is a bit different – we need to put the pointer to the new *.ssdl, change provider name and add new keyword to provider connection string:</P><PRE class=csharpcode><SPAN class=kwrd>&lt;</SPAN><SPAN class=html>connectionStrings</SPAN><SPAN class=kwrd>&gt;</SPAN>
  <SPAN class=kwrd>&lt;</SPAN><SPAN class=html>add</SPAN> <SPAN class=attr>name</SPAN><SPAN class=kwrd>="NorthwindEntities"</SPAN>
       <SPAN class=attr>connectionString</SPAN><SPAN class=kwrd>="metadata=NorthwindEFModel.csdl | NorthwindEFModel.msl | <STRONG><U><FONT size=3>NorthwindEFModel.Modified.ssdl</FONT></U></STRONG>;
                         provider=<STRONG><U><FONT size=3>EFCachingProvider</FONT></U></STRONG>; 
                         provider connection string=&amp;quot;<U><FONT size=3><STRONG>wrappedProvider=System.Data.SqlClient;</STRONG></FONT></U>Data Source=.\sqlexpress;<BR>Initial Catalog=NorthwindEF;Integrated Security=True;MultipleActiveResultSets=True&amp;quot;"</SPAN>
       <SPAN class=attr>providerName</SPAN><SPAN class=kwrd>="System.Data.EntityClient"</SPAN> <SPAN class=kwrd>/&gt;</SPAN>
<SPAN class=kwrd>&lt;/</SPAN><SPAN class=html>connectionStrings</SPAN><SPAN class=kwrd>&gt;</SPAN></PRE>
<H5>Specifying tracing configuration in the configuration file:</H5>
<P>It is also possible to specify tracing configuration in App.config file. The following parameters are available:</P><PRE class=csharpcode><SPAN class=kwrd>&lt;</SPAN><SPAN class=html>appSettings</SPAN><SPAN class=kwrd>&gt;</SPAN>
  <SPAN class=rem>&lt;!-- write log messages to the console. --&gt;</SPAN>
  <SPAN class=kwrd>&lt;</SPAN><SPAN class=html>add</SPAN> <SPAN class=attr>key</SPAN><SPAN class=kwrd>="EFTracingProvider.logToConsole"</SPAN> <SPAN class=attr>value</SPAN><SPAN class=kwrd>="true"</SPAN> <SPAN class=kwrd>/&gt;</SPAN>
    
  <SPAN class=rem>&lt;!-- append log messages to the specified file --&gt;</SPAN>
  <SPAN class=kwrd>&lt;</SPAN><SPAN class=html>add</SPAN> <SPAN class=attr>key</SPAN><SPAN class=kwrd>="EFTracingProvider.logToFile"</SPAN> <SPAN class=attr>value</SPAN><SPAN class=kwrd>="sqllog.txt"</SPAN> <SPAN class=kwrd>/&gt;</SPAN>
<SPAN class=kwrd>&lt;/</SPAN><SPAN class=html>appSettings</SPAN><SPAN class=kwrd>&gt;</SPAN></PRE>
<H3>Limitations and Disclaimers</H3>
<P>The providers have not been extensively tested beyond what’s included in the sample code, so you should use tem at your own risk. </P>
<P>As with any other sample, Microsoft is not offering any kind of support for it, but if you find bugs or have feature suggestions, please use this blog’s contact form and let me know about them.</P>]]></content:encoded>
    </item>
    <item>
      <title>Entity Framework samples converted to Visual Basic</title>
      <link>https://docs.microsoft.com/archive/blogs/jkowalski/entity-framework-samples-converted-to-visual-basic</link>
      <pubDate>Thu, 21 May 2009 13:46:00 GMT</pubDate>
      <dc:creator><![CDATA[Jaroslaw Kowalski - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jkowalski/2009/05/21/entity-framework-samples-converted-to-visual-basic/</guid>
      <description><![CDATA[We have recently published Visual Basic versions of our MSDN Code Gallery samples for Entity...]]></description>
      <content:encoded><![CDATA[<P>We have recently published Visual Basic versions of our MSDN Code Gallery samples for Entity Framework v3.5SP1.</P>
<P>The following translated samples are currently available in two languages (C# and VB)</P>
<P>ADO.NET Entity Framework Query Samples<BR><A href="https://code.msdn.com/EFQuerySamples" mce_href="https://code.msdn.com/EFQuerySamples">https://code.msdn.com/EFQuerySamples</A></P>
<P>Persistence Ignorance (POCO) Adapter for Entity Framework<BR><A href="https://code.msdn.com/EFPocoAdapter" mce_href="https://code.msdn.com/EFPocoAdapter">https://code.msdn.com/EFPocoAdapter</A></P>
<P>Transparent Lazy Loading for Entity Framework<BR><A href="https://code.msdn.com/EFLazyLoading" mce_href="https://code.msdn.com/EFLazyLoading">https://code.msdn.com/EFLazyLoading</A></P>
<P>The samples have been fully converted to use and generate Visual Basic&nbsp;code instead of C#. More samples are in the pipeline and will be published soon - stay tuned. </P>
<P>Full list of current EF samples published by the Entity Framework team is always available at:<BR><A href="https://code.msdn.microsoft.com/adonetefx" mce_href="https://code.msdn.microsoft.com/adonetefx">https://code.msdn.microsoft.com/adonetefx</A></P>
<P mce_keep="true">&nbsp;</P>
<P mce_keep="true">&nbsp;</P>
<P mce_keep="true">&nbsp;</P>
<P mce_keep="true">&nbsp;</P>]]></content:encoded>
    </item>
    <item>
      <title>New posts on EF Design Blog</title>
      <link>https://docs.microsoft.com/archive/blogs/jkowalski/new-posts-on-ef-design-blog</link>
      <pubDate>Mon, 23 Mar 2009 22:42:04 GMT</pubDate>
      <dc:creator><![CDATA[Jaroslaw Kowalski - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jkowalski/2009/03/23/new-posts-on-ef-design-blog/</guid>
      <description><![CDATA[I’d like to turn your attention to two blog posts on EF Design Blog about exciting new features...]]></description>
      <content:encoded><![CDATA[<p>I’d like to turn your attention to two blog posts on <a href="https://blogs.msdn.com/efdesign/">EF Design Blog</a> about exciting new features planned for Entity Framework:</p>  <ul>   <li><a href="https://blogs.msdn.com/efdesign/archive/2009/03/16/foreign-keys-in-the-entity-framework.aspx">Foreign Key Support</a> – we’re introducing new type of association, which can be manipulated through references OR foreign key values available on entities themselves. We believe that this will greatly improve scenarios such as data binding, disconnected entities (N-Tier) and many others.</li>    <li><a href="https://blogs.msdn.com/efdesign/archive/2009/03/24/self-tracking-entities-in-the-entity-framework.aspx">Self-Tracking-Entities</a> – it’s a simple way to have your entities track their state across tiers (based on custom code generation) and simple mechanism to save those changes to the database.</li> </ul>  <p>Your feedback is very important to us, please tell us what you think about those new features!</p>]]></content:encoded>
    </item>
    <item>
      <title>N-Tier Improvements for Entity Framework</title>
      <link>https://docs.microsoft.com/archive/blogs/jkowalski/n-tier-improvements-for-entity-framework</link>
      <pubDate>Thu, 20 Nov 2008 12:09:00 GMT</pubDate>
      <dc:creator><![CDATA[Jaroslaw Kowalski - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jkowalski/2008/11/20/n-tier-improvements-for-entity-framework/</guid>
      <description><![CDATA[We have recently published an article on API changes that we want to make in next version of Entity...]]></description>
      <content:encoded><![CDATA[<P>We have recently published an article on API changes that we want to make in next version of Entity Framework in order to enable more N-Tier scenarios. Getting this right is very important to us and we're interested in getting as much of your feedback on the proposed design as possible. </P>
<P>Please read and comment on the article at: <A href="https://blogs.msdn.com/efdesign/archive/2008/11/20/n-tier-improvements-for-entity-framework.aspx" mce_href="https://blogs.msdn.com/efdesign/archive/2008/11/20/n-tier-improvements-for-entity-framework.aspx">https://blogs.msdn.com/efdesign/archive/2008/11/20/n-tier-improvements-for-entity-framework.aspx</A></P>]]></content:encoded>
    </item>
    <item>
      <title>Using EF Oracle Sample Provider with EDM Designer</title>
      <link>https://docs.microsoft.com/archive/blogs/jkowalski/using-ef-oracle-sample-provider-with-edm-designer</link>
      <pubDate>Fri, 24 Oct 2008 13:24:49 GMT</pubDate>
      <dc:creator><![CDATA[Jaroslaw Kowalski - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jkowalski/2008/10/24/using-ef-oracle-sample-provider-with-edm-designer/</guid>
      <description><![CDATA[Many people are asking if it is possible to use EFOracleProvider with EDM Designer in Visual Studio...]]></description>
      <content:encoded><![CDATA[<p>Many people are asking if it is possible to use <a href="https://code.msdn.microsoft.com/EFOracleProvider">EFOracleProvider</a> with EDM Designer in Visual Studio 2008 SP1. The answer is yes, but because the sample doesn't include a DDEX provider required for VS integration, there are certain steps that have to be run manually. </p>  <p>I've compiled a step-by-step guide for those interested in trying this out (this assumes NorthwindEF sample database installed according to instructions included with the sample, but it should be straightforward to adjust it to your own setup)</p>  <h2>PART 1 : INSTALLING ORACLE SAMPLE PROVIDER</h2>  <p>1. Download and unzip EFOracleSampleProvider.zip from <a href="https://code.msdn.com/EFOracleProvider">https://code.msdn.com/EFOracleProvider</a> </p>  <p>2. Follow instructions in the README.txt to set up a sample database. </p>  <p>3. Open elevated Visual Studio instance. Build the sample project. </p>  <p>4. Open elevated command prompt and open machine.config using notepad:&#160; <br /><strong>notepad %WINDIR%\Microsoft.NET\Framework\v2.0.50727\config\machine.config</strong> </p>  <p>5. Find &lt;DbProviderFactories&gt; section and add EFOracleProvider entry:</p>  <pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">add</span> <span class="attr">name</span><span class="kwrd">=&quot;EF Oracle Data Provider&quot;</span> <span class="attr">invariant</span><span class="kwrd">=&quot;EFOracleProvider&quot;</span> 
     <span class="attr">description</span><span class="kwrd">=&quot;EF Provider for Oracle testing&quot;</span> 
     <span class="attr">type</span><span class="kwrd">=&quot;EFOracleProvider.EFOracleProviderFactory, EFOracleProvider, Version=1.0.0.0, Culture=neutral, PublicKeyToken=def642f226e0e59b&quot;</span><span class="kwrd">/&gt;</span></pre>

<p>6. The completed system.data section has to look similar to this: </p>

<pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">system.data</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;</span><span class="html">DbProviderFactories</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">add</span> <span class="attr">name</span><span class="kwrd">=&quot;Odbc Data Provider&quot;</span> <span class="attr">invariant</span><span class="kwrd">=&quot;System.Data.Odbc&quot;</span> <span class="attr">description</span><span class="kwrd">=&quot;.Net Framework Data Provider for Odbc&quot;</span> <span class="attr">type</span><span class="kwrd">=&quot;System.Data.Odbc.OdbcFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&quot;</span><span class="kwrd">/&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">add</span> <span class="attr">name</span><span class="kwrd">=&quot;OleDb Data Provider&quot;</span> <span class="attr">invariant</span><span class="kwrd">=&quot;System.Data.OleDb&quot;</span> <span class="attr">description</span><span class="kwrd">=&quot;.Net Framework Data Provider for OleDb&quot;</span> <span class="attr">type</span><span class="kwrd">=&quot;System.Data.OleDb.OleDbFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&quot;</span><span class="kwrd">/&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">add</span> <span class="attr">name</span><span class="kwrd">=&quot;OracleClient Data Provider&quot;</span> <span class="attr">invariant</span><span class="kwrd">=&quot;System.Data.OracleClient&quot;</span> <span class="attr">description</span><span class="kwrd">=&quot;.Net Framework Data Provider for Oracle&quot;</span> <span class="attr">type</span><span class="kwrd">=&quot;System.Data.OracleClient.OracleClientFactory, System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&quot;</span><span class="kwrd">/&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">add</span> <span class="attr">name</span><span class="kwrd">=&quot;SqlClient Data Provider&quot;</span> <span class="attr">invariant</span><span class="kwrd">=&quot;System.Data.SqlClient&quot;</span> <span class="attr">description</span><span class="kwrd">=&quot;.Net Framework Data Provider for SqlServer&quot;</span> <span class="attr">type</span><span class="kwrd">=&quot;System.Data.SqlClient.SqlClientFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&quot;</span><span class="kwrd">/&gt;</span>
    <strong><em><span class="kwrd">&lt;</span><span class="html">add</span> <span class="attr">name</span><span class="kwrd">=&quot;EF Oracle Data Provider&quot;</span> <span class="attr">invariant</span><span class="kwrd">=&quot;EFOracleProvider&quot;</span> <span class="attr">description</span><span class="kwrd">=&quot;EF Provider for Oracle testing&quot;</span> <span class="attr">type</span><span class="kwrd">=&quot;EFOracleProvider.EFOracleProviderFactory, EFOracleProvider, Version=1.0.0.0, Culture=neutral, PublicKeyToken=def642f226e0e59b&quot;</span><span class="kwrd">/&gt;</span>
</em></strong>    <span class="kwrd">&lt;</span><span class="html">add</span> <span class="attr">name</span><span class="kwrd">=&quot;Microsoft SQL Server Compact Data Provider&quot;</span> <span class="attr">invariant</span><span class="kwrd">=&quot;System.Data.SqlServerCe.3.5&quot;</span> <span class="attr">description</span><span class="kwrd">=&quot;.NET Framework Data Provider for Microsoft SQL Server Compact&quot;</span> <span class="attr">type</span><span class="kwrd">=&quot;System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=3.5.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91&quot;</span><span class="kwrd">/&gt;</span>
  <span class="kwrd">&lt;/</span><span class="html">DbProviderFactories</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">system.data</span><span class="kwrd">&gt;</span></pre>

<h2>PART 2: GENERATING MODEL FROM ORACLE DATABASE</h2>

<p>7. Create a new project in VS. For simplicity let's create a console application</p>

<p>8. Open elevated command prompt. Enter the directory that contains the newly created project and run the following command:</p>

<pre class="csharpcode">%WINDIR%\Microsoft.NET\Framework\v3.5\edmgen.exe /provider:EFOracleProvider /mode:fullgeneration <br />      /connectionstring:<span class="str">&quot;data source=XE;user id=edmuser;password=123456&quot;</span> /project:NorthwindEFModel<br /></pre>

<p>The output should be:</p>

<pre class="csharpcode">Microsoft (R) EdmGen version 3.5.0.0
Copyright (C) 2008 Microsoft Corporation. All rights reserved.

Loading database information...
warning 6005: The data type <span class="str">'timestamp(9)'</span> is not supported, the column <span class="str">'OrderDate'</span> <span class="kwrd">in</span> table <span class="str">'dbo.Orders'</span> was excluded.
warning 6005: The data type <span class="str">'timestamp(3)'</span> is not supported, the column <span class="str">'RequiredDate'</span> <span class="kwrd">in</span> table <span class="str">'dbo.Orders'</span> was excluded.
Writing ssdl file...
Creating conceptual layer from storage layer...
Writing msl file...
Writing csdl file...
Writing object layer file...
Writing views file...

Generation Complete -- 0 errors, 2 warnings</pre>

<p>9. This will create a bunch of NorthwindEFModel.* files for you.</p>

<p>10. Open Northwind.ssdl file in a text editor and replace all instances of Schema=&quot;dbo&quot; with empty string (this is needed because tables in the sample Oracle database don't use a schema)</p>

<p>11. In order to use generated model in the EF Ddesigner, we have to create NorthwindEFModel.edmx file. This can be done manually (just copy/paste contents of individual files into an empty EDMX as indicated by the comments) or by using <a href="https://code.msdn.com/EdmGen2">EdmGen2 tool from Code Gallery</a>:</p>

<pre class="csharpcode">C:\Path\To\EdmGen2.exe /toedmx NorthwindEFModel.csdl NorthwindEFModel.ssdl NorthwindEFModel.msl</pre>

<p>12. This will create NorthwindEFModel.edmx, which we can add to the project in VS. </p>

<p>13. At this point you can now delete the following files generated by EdmGen.exe, which won't be necessary:</p>

<ul>
  <li>NorthwindEFModel.csdl </li>

  <li>NorthwindEFModel.ssdl </li>

  <li>NorthwindEFModel.msl </li>

  <li>NorthwindEFModel.ObjectLayer.cs </li>

  <li>NorthwindEFModel.Views.cs </li>
</ul>

<h2>PART 3: TESTING GENERATED MODEL</h2>

<p>14. The only remaining thing to do is to add App.config file with connection string for our Oracle database:</p>

<pre class="csharpcode"><span class="kwrd">&lt;?</span><span class="html">xml</span> <span class="attr">version</span><span class="kwrd">=&quot;1.0&quot;</span> <span class="attr">encoding</span><span class="kwrd">=&quot;utf-8&quot;</span> ?<span class="kwrd">&gt;</span>
<span class="kwrd">&lt;</span><span class="html">configuration</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;</span><span class="html">connectionStrings</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">add</span> <span class="attr">name</span><span class="kwrd">=&quot;NorthwindEFModelContext&quot;</span> 
         <span class="attr">connectionString</span><span class="kwrd">=&quot;provider=EFOracleProvider;
                           metadata=res://*/NorthwindEFModel.csdl|res://*/NorthwindEFModel.ssdl|res://*/NorthwindEFModel.msl;
                           Provider Connection String='data source=XE;user id=edmuser;password=123456'&quot;</span> 
         <span class="attr">providerName</span><span class="kwrd">=&quot;System.Data.EntityClient&quot;</span> <span class="kwrd">/&gt;</span>
  <span class="kwrd">&lt;/</span><span class="html">connectionStrings</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">configuration</span><span class="kwrd">&gt;</span></pre>

<p>15. We can now try out our model by running a sample LINQ to Entities query:</p>

<pre class="csharpcode"><span class="kwrd">using</span> (NorthwindEFModelContext context = <span class="kwrd">new</span> NorthwindEFModelContext())
{
    <span class="kwrd">foreach</span> (var c <span class="kwrd">in</span> context.Customers.Where(c=&gt;c.City == <span class="str">&quot;Seattle&quot;</span>))
    {
        Console.WriteLine(c.CompanyName);
    }
}</pre>]]></content:encoded>
    </item>
    <item>
      <title>EF POCO Adapter updated (v1.03)</title>
      <link>https://docs.microsoft.com/archive/blogs/jkowalski/ef-poco-adapter-updated-v1-03</link>
      <pubDate>Thu, 25 Sep 2008 23:24:05 GMT</pubDate>
      <dc:creator><![CDATA[Jaroslaw Kowalski - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jkowalski/2008/09/25/ef-poco-adapter-updated-v1-03/</guid>
      <description><![CDATA[I've just posted another round of updates to EF POCO Adapter based on feedback from users. This set...]]></description>
      <content:encoded><![CDATA[<p>I've just posted another round of updates to EF POCO Adapter based on feedback from users. This set of changes is focused on N-tier scenarios and detached entities (it adds missing wrappers for EF APIs and fixes behavior of existing ones).</p> <p>Change log:</p> <ul> <li>Added wrapper for ObjectContext.ApplyPropertyChanges() to IEntitySet&lt;T&gt;  <li>Added wrapper for ObjectContext.Detach() to IEntitySet&lt;T&gt;  <li>Fixed handling of detached/out-of-scope entities w.r.t lazy loading and attaching to other contexts. Lazy loading outside of scope will do nothing if the context had DeferredLoadingEnabled=false, otherwise will throw.  <li>Added partial OnZZZCreated() methods on generated contexts, adapters and proxies to enable integration with 3rd-party extensions  <li>Fixed code generation from EDMX.  <li>EFPocoContext.EnableLazyLoading has been renamed to EFPocoContext.DeferredLoadingEnabled to better align with Linq to SQL and our plans for EF v2  <li>Fixed adapter-POCO synchronization for complex types</li></ul> <p>The new release is here: <a href="https://code.msdn.microsoft.com/EFPocoAdapter/Release/ProjectReleases.aspx?ReleaseId=1580">https://code.msdn.microsoft.com/EFPocoAdapter/Release/ProjectReleases.aspx?ReleaseId=1580</a></p> <p>Big thanks to everyone who sent me comments, bug reports and improvement suggestions for this release. This is very valuable feedback as it allows us to better understand user scenarios around POCOs for EF v2.</p>]]></content:encoded>
    </item>
    <item>
      <title>EF POCO Adapter updated (v1.02)</title>
      <link>https://docs.microsoft.com/archive/blogs/jkowalski/ef-poco-adapter-updated-v1-02</link>
      <pubDate>Sat, 13 Sep 2008 19:36:38 GMT</pubDate>
      <dc:creator><![CDATA[Jaroslaw Kowalski - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jkowalski/2008/09/13/ef-poco-adapter-updated-v1-02/</guid>
      <description><![CDATA[I've just posted updates to EF POCO Adapter (v1.02) which resolves a couple of issues spotted by...]]></description>
      <content:encoded><![CDATA[<p>I've just posted updates to EF POCO Adapter (v1.02) which resolves a couple of issues spotted by users:</p> <ol> <li>Detached proxies (created by EFPocoContxt.CreateObject&lt;T&gt;) as well as proxies in the Added state were failing on property navigation. This has been fixed, and the property navigation doesn't attempt the load in one of these states. Thanks to <a href="https://polymorphicview.blogspot.com/">Corey Gaudin</a> for reporting this.</li> <li>GetAdapterObject() was failing for proxies created with CreateObject&lt;T&gt;. This has been fixed by ensuring that adapters are always cached whenever proxies are present. As a side effect of this change, DetectChanges() should be a bit faster, as we don't have to walk object state manager anymore. Thanks to Corey Gaudin for reporting this.</li> <li>Fixed code generator to eliminate compilation warning of unused property.</li></ol> <p>The updated version is available <a href="https://code.msdn.microsoft.com/Release/ProjectReleases.aspx?ProjectName=EFPocoAdapter&amp;ReleaseId=1537">here</a>.</p>]]></content:encoded>
    </item>
  </channel>
</rss>