MVC with Schema firsthttp://forums.asp.net/t/1796891.aspx/1?MVC+with+Schema+firstWed, 25 Apr 2012 15:10:46 -040017968914951150http://forums.asp.net/p/1796891/4951150.aspx/1?MVC+with+Schema+firstMVC with Schema first <p>How do I create a database context for MVC if I already have a database? Please provide a link with some sample code.</p> <p>(All the sample i find wants to do code first.)</p> 2012-04-25T15:02:27-04:004951163http://forums.asp.net/p/1796891/4951163.aspx/1?Re+MVC+with+Schema+firstRe: MVC with Schema first <p>You can most definitely build a context database first. In fact one of the modes you can use Entity Framework is EF Database First. In this case you can just create an edmx file and drag your tables and it generates the data context for you<br> <a href="http://msdn.microsoft.com/en-us/data/gg685489">http://msdn.microsoft.com/en-us/data/gg685489</a></p> <p><a href="http://msdn.microsoft.com/en-us/data/gg685489"></a>If you don't want to use full fledged entities, you can still use EF code first models (raw pocos) with an existing database.<br> See this blog post on how to do that. ( you can easily modify th technique used in this post to work with mvc)<br> <a href="http://weblogs.asp.net/scottgu/archive/2010/08/03/using-ef-code-first-with-an-existing-database.aspx">http://weblogs.asp.net/scottgu/archive/2010/08/03/using-ef-code-first-with-an-existing-database.aspx</a>&nbsp;</p> <p>Also check out<br> <a href="http://weblogs.asp.net/jgalloway/archive/2011/02/24/generating-ef-code-first-model-classes-from-an-existing-database.aspx">http://weblogs.asp.net/jgalloway/archive/2011/02/24/generating-ef-code-first-model-classes-from-an-existing-database.aspx</a>&nbsp;</p> 2012-04-25T15:09:27-04:004951167http://forums.asp.net/p/1796891/4951167.aspx/1?Re+MVC+with+Schema+firstRe: MVC with Schema first <p>Hi,</p> <p></p> <blockquote><span class="icon-blockquote"></span> <h4>Arne Garvander</h4> How do I create a database context for MVC if I already have a database?</blockquote> <p></p> <p>If I understand your question correctly you're looking for this: <a href="http://msdn.microsoft.com/en-us/data/gg685489" target="_blank"> Building an MVC 3 App with Database First and Entity Framework</a>.</p> <p>Grz, Kris.</p> 2012-04-25T15:10:46-04:00