<?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 Database Generation Error</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2012 : Code First Database Generation Error</description>
  <pubDate>Thu, 14 May 2026 08:18:23 -700</pubDate>
  <lastBuildDate>Fri, 11 Jan 2013 12:02:07 -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=3883</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 Database Generation Error :   OK, thanks for reporting this....</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3883&amp;PID=15558#15558</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=11" rel="nofollow">kimj</a><br /><strong>Subject:</strong> 3883<br /><strong>Posted:</strong> 11-Jan-2013 at 12:02pm<br /><br />OK, thanks for reporting this.]]>
   </description>
   <pubDate>Fri, 11 Jan 2013 12:02:07 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3883&amp;PID=15558#15558</guid>
  </item> 
  <item>
   <title>Code First Database Generation Error : Sql Server 2008 R2 and DevForce...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3883&amp;PID=15557#15557</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=579" rel="nofollow">gregweb</a><br /><strong>Subject:</strong> 3883<br /><strong>Posted:</strong> 11-Jan-2013 at 10:49am<br /><br />Sql Server 2008 R2 and DevForce 7.0.3<br /><br />But I think I know the issue - what was kicking off the database creation was adding an Entity and then saving it.<br /><br />When I changed the kickoff to a query, then it ran without error.  I think somehow the Database Creation and the save operation were somehow getting wrapped up into one transaction.<br /><br />But this is resolved as far as I am concerned.<br /><br />Greg]]>
   </description>
   <pubDate>Fri, 11 Jan 2013 10:49:09 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3883&amp;PID=15557#15557</guid>
  </item> 
  <item>
   <title>Code First Database Generation Error :   We had this problem back in...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3883&amp;PID=15555#15555</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=11" rel="nofollow">kimj</a><br /><strong>Subject:</strong> 3883<br /><strong>Posted:</strong> 11-Jan-2013 at 9:52am<br /><br />We had this problem back in the early days of DevForce Code First support and it was fixed in version 6.1.3, so it's not good that it's popped up again.<div>&nbsp;</div>Which version/edition of SQL Server are you running?&nbsp;]]>
   </description>
   <pubDate>Fri, 11 Jan 2013 09:52:40 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3883&amp;PID=15555#15555</guid>
  </item> 
  <item>
   <title>Code First Database Generation Error : I have a very simple test project...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3883&amp;PID=15553#15553</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=579" rel="nofollow">gregweb</a><br /><strong>Subject:</strong> 3883<br /><strong>Posted:</strong> 10-Jan-2013 at 7:56pm<br /><br />I have a very simple test project based on the CodeFirstWalk in Silverlight with a connection string in web.config to Sql Server.<br /><br />When I fire it up and run it, when there is no existing database, it throws the following error:<br /><br />System.Data.SqlClient.SqlException: CREATE DATABASE statement not allowed within multi-statement transaction.<br />&nbsp;&nbsp;&nbsp;at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)<br /><br />The odd part of this is that the database is in fact created, and the data properly saved to the database.<br /><br />After the first run, there is no error as of course the database is already there and additional data is saved.<br /><br />The code is very straightforward:<br /><br />public class ProductEntities : EntityManager {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public EntityQuery&lt;Category&gt; Categories { get; set; } <br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&#091;ProvideEntityAspect&#093;<br />&nbsp;&nbsp;&nbsp;&nbsp;public class Category<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public int CategoryId { get; set; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public string CategoryName { get; set; }<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br /><br />public class MainPageViewModel<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private ProductEntities Manager { get; set; }<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public MainPageViewModel() {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SetManager();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AddTestData();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private void AddTestData()<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var cat = new Category { CategoryName = "Sweet Things on " + DateTime.Now.ToString("o") };<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Manager.AddEntity(cat);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Manager.SaveChangesAsync();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private void SetManager()<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Manager = new ProductEntities();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Manager.EntityServerError += (s, e) =&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  e.Handled = true; // we're dealing with it here<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  MessageBox.Show(e.Exception.Message);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  Manager.RejectChanges(); // undo pending changes<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;};<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Manager.SaveChangesAsync();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br /><br /><br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />This is not a big issue, it just makes no sense to me.<br /><br />Greg]]>
   </description>
   <pubDate>Thu, 10 Jan 2013 19:56:22 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3883&amp;PID=15553#15553</guid>
  </item> 
 </channel>
</rss>