<?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 : Shared sub-models</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2010 : Shared sub-models</description>
  <pubDate>Mon, 13 Apr 2026 13:05:39 -700</pubDate>
  <lastBuildDate>Wed, 01 Feb 2012 09:05:49 -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=3240</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>Shared sub-models :   Hi Chuck,You will indeed need...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3240&amp;PID=12595#12595</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> 3240<br /><strong>Posted:</strong> 01-Feb-2012 at 9:05am<br /><br />Hi Chuck,<div>&nbsp;</div><div>You will indeed need to have two EntityManagers (one for Law and one for Publishing) if you want to share the User model.</div><div>&nbsp;</div><div>Note that when coding the navigation properties, that could be done only in one direction or you will have a circular reference error.</div><div>Code First wouldn't have any advantage and the only difference is that you'd be coding the navigation properties in the entity in Code First and in the partial class otherwise.</div><div>Also, injecting the properties using PostSharp won’t be that useful because you would want to reference the properties in code at compile time. (we use PostSharp to inject behaviors that are discovered at runtime)</div><div>&nbsp;</div><div>I'd suggest to implement a repository pattern.&nbsp;The repository would include methods to fetch entities across models.</div><div>i.e.&nbsp;</div><div><em>public User Repository.GetUser(Attorney attorney) { … }</em></div><div><div>&nbsp;</div><div>You can find more information about the repository pattern at <a href="http://msdn.microsoft.com/en-us/library/ff649690.aspx" target="_blank">http://msdn.microsoft.com/en-us/library/ff649690.aspx</a>.</div><div>&nbsp;</div><div>Regards,</div><div>&nbsp;&nbsp; Silvio.</div></div>]]>
   </description>
   <pubDate>Wed, 01 Feb 2012 09:05:49 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3240&amp;PID=12595#12595</guid>
  </item> 
  <item>
   <title>Shared sub-models : Given a simple example scenario...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3240&amp;PID=12571#12571</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=705" rel="nofollow">chuckc</a><br /><strong>Subject:</strong> 3240<br /><strong>Posted:</strong> 29-Jan-2012 at 3:22pm<br /><br /><p ="Ms&#111;normal">Given a simple example scenario where we have two databasesthat share some common tables, such as:<o:p></o:p></p><p ="Ms&#111;normal"><span ="Apple-tab-span" style="white-space:pre">	</span>Publishing DB: Author, Book, User, Permission,PermissionGroup<o:p></o:p></p><p ="Ms&#111;normal"><span ="Apple-tab-span" style="white-space:pre">	</span>Law DB: Attorney, CourtCase, Plaintiff, User, Permission,PermissionGroup<o:p></o:p></p><p ="Ms&#111;normal">We want an assembly that manages user permissions which onlyneed access to the User, Permission and PermissionGroup tables.&nbsp; We would like this User focused assembly tobe common and shared in two separate Law and Publishing projects.&nbsp; This seems to indicate three separate models:</p><p ="Ms&#111;normal"><span style="text-indent: -0.25in; "><span ="Apple-tab-span" style="white-space:pre">	</span>1. User model containing User, Permission,PermissionGroup</span></p><p ="Ms&#111;normal"><span style="text-indent: -0.25in; "><span ="Apple-tab-span" style="white-space:pre">	</span>2. Publishing model containing just Author and Book(without User, etc.)</span><span style="text-indent: -0.25in; ">.</span></p><p ="Ms&#111;normal"><span style="text-indent: -0.25in; "><span ="Apple-tab-span" style="white-space:pre">	</span>3. Law model containing just Attorney and CourtCase(without User, etc.)</span></p><p ="MsoListParagraphCxSpLast" style="text-indent:-.25in;mso-list:l0 level1 lfo1"><o:p></o:p></p><p ="Ms&#111;normal">I understand that multiple models used in a singleEntityManager cannot contain duplicate entities, so the Law and Publishing modelscould not contain User entities directly.<o:p></o:p></p><p ="Ms&#111;normal">This implies a need to manually code navigation properties ineach of the Publishing and Law models to support navigation operations like Attorney.User.Permissions.<o:p></o:p></p><p ="Ms&#111;normal">So, given the above, what are the best approach(s)to take?&nbsp; Does Code First (or CodeSecond) offer significant advantages?&nbsp; CouldI perhaps leverage PostSharp to inject User properties on any entity class thathas a UserID property as opposed to manual coding?<o:p></o:p></p><p ="Ms&#111;normal">Or would it be more practical to just include User entitiesin the Publishing and Law models directly and use a separate EntityManager whenworking with User entities in the shared User assembly? &nbsp;That implies updates to three models when something changes with User, but maybe that is still the cleanest approach.<o:p></o:p></p><p ="Ms&#111;normal">Thanks for any and all thoughts.</p><p ="Ms&#111;normal"><br></p>]]>
   </description>
   <pubDate>Sun, 29 Jan 2012 15:22:31 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3240&amp;PID=12571#12571</guid>
  </item> 
 </channel>
</rss>