<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="http://syndication.webwiz.co.uk/rss_namespace/">
 <channel>
  <title>DevForce Community Forum : Code First Migration using DataSourceKey</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2010 : Code First Migration using DataSourceKey</description>
  <pubDate>Wed, 13 May 2026 01:05:40 -700</pubDate>
  <lastBuildDate>Mon, 26 Nov 2012 22:50:52 -700</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 9.69</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>www.ideablade.com/forum/RSS_post_feed.asp?TID=3800</WebWizForums:feedURL>
  <image>
   <title>DevForce Community Forum</title>
   <url>http://www.ideablade.com/forum/forum_images/IdeaBlade_logo_tm.png</url>
   <link>http://www.ideablade.com/forum/</link>
  </image>
  <item>
   <title>Code First Migration using DataSourceKey : Hi Koen,We have created a workaround...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3800&amp;PID=15280#15280</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1228" rel="nofollow">Vonzkie</a><br /><strong>Subject:</strong> 3800<br /><strong>Posted:</strong> 26-Nov-2012 at 10:50pm<br /><br />Hi Koen,<div><br></div><div>We have created a workaround that might help you as well.</div><div><br></div><div>On your Custom DbContext:</div><div><br></div><div><div>&nbsp; &nbsp; public class GlobalDBContext : DbContext</div><div>&nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; public GlobalDBContext() :</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;base(Web.GetLatestMigrationConnection("MyEntities") ?? "name=MyEntities")</div><div>&nbsp; &nbsp; &nbsp; &nbsp; {</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div></div><div>&nbsp; &nbsp; }</div><div><br></div><div>Just add a <b>method call </b>on the base Constructor parameter that compose your connection string on runtime.</div><div><br></div><div>Note that when you're creating migration script via Package Manager Console (Add-Migration 'Something') you need to comment out this<b><i> base(Web.GetLatestMigrationConnection("MyEntities") ?? "name=MyEntities")</i></b></div><div>and replace it with a basic base("name=MyEntities") that gets connection string from your app.config.</div><div>The code that I gave you above only works on production runtime. :)</div><div><br></div><div>Thanks,</div><div>Von</div><div><br></div><div><br></div>]]>
   </description>
   <pubDate>Mon, 26 Nov 2012 22:50:52 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3800&amp;PID=15280#15280</guid>
  </item> 
  <item>
   <title>Code First Migration using DataSourceKey : Any answers to this question,...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3800&amp;PID=15279#15279</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=595" rel="nofollow">sky40627</a><br /><strong>Subject:</strong> 3800<br /><strong>Posted:</strong> 26-Nov-2012 at 10:38pm<br /><br />Any answers to this question, I am trying to do the same.<br /><br />Without any luck so far.<br /><br />I also have a BOS that can connect to different databases.<br /><br />Thx<br /><br />Koen]]>
   </description>
   <pubDate>Mon, 26 Nov 2012 22:38:38 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3800&amp;PID=15279#15279</guid>
  </item> 
  <item>
   <title>Code First Migration using DataSourceKey : Hi Silvio,Thanks for the info.However,...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3800&amp;PID=15211#15211</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1228" rel="nofollow">Vonzkie</a><br /><strong>Subject:</strong> 3800<br /><strong>Posted:</strong> 15-Nov-2012 at 2:57pm<br /><br />Hi Silvio,<div><br></div><div>Thanks for the info.</div><div>However, do you have an idea if EF has a dynamic way on constructing the connection string on Migration?</div><div><br></div><div>I ask this because our BOS' model handles not only one connection to the database and we use IDatasourceKeyResolver to compose the connection string.</div><div><br></div><div>Model1 can connection to Database A, Database B, Database C. So how do I perform automatic migration here in the production environment?</div><div><br></div><div>Thanks,</div><div>Von</div>]]>
   </description>
   <pubDate>Thu, 15 Nov 2012 14:57:53 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3800&amp;PID=15211#15211</guid>
  </item> 
  <item>
   <title>Code First Migration using DataSourceKey :   Hi Von,Since Migration does...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3800&amp;PID=15210#15210</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=892" rel="nofollow">sbelini</a><br /><strong>Subject:</strong> 3800<br /><strong>Posted:</strong> 15-Nov-2012 at 10:58am<br /><br />Hi Von,<div>&nbsp;</div><div>Since Migration does not rely on DevForce, (i.e. it's pure EF) IDataSourceKeyResolver does not play a role in it and you will have to use the connectionString in the .config file.</div><div>&nbsp;</div><div>&nbsp;&nbsp; sbelini.</div>]]>
   </description>
   <pubDate>Thu, 15 Nov 2012 10:58:40 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3800&amp;PID=15210#15210</guid>
  </item> 
  <item>
   <title>Code First Migration using DataSourceKey : Hi,We are trying to use Code First...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3800&amp;PID=15209#15209</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1228" rel="nofollow">Vonzkie</a><br /><strong>Subject:</strong> 3800<br /><strong>Posted:</strong> 15-Nov-2012 at 2:43am<br /><br />Hi,<div><br></div><div>We are trying to use Code First Migration in our database and it works well but the limitation is the connection string should be in the Web.config.</div><div><br></div><div>How can we do this process by invoking the IDataSourceKeyResolver or any way to dynamically compose the connection string to update the database.</div><div><br></div><div>Note that I'm doing the Update-Database command via code not in the Package Manager Console.</div><div><br></div><div><div>var migratorConfig = new Model.Migrations.Configuration();</div><div>var dbMigrator = new DbMigrator(migratorConfig);</div><div>dbMigrator.Configuration.AutomaticMigrationDataLossAllowed = false;</div><div>dbMigrator.Update();</div></div><div><br></div><div>Thanks,</div><div>Von</div>]]>
   </description>
   <pubDate>Thu, 15 Nov 2012 02:43:52 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3800&amp;PID=15209#15209</guid>
  </item> 
 </channel>
</rss>