sjnaughton I was able to find another way without having to delete the TT files or change Code Generation to Default.
Here is the Link: http://blog.davidebbo.com/2011/01/using-dynamic-data-with-ef-code-first.html
This is a direct copy of the portion that works:
Approach #1: dig the ObjectContext out of the DbContext
The workaround is quite simple. In your RegisterRoutes method in global.asax, just add the following code (you’ll need to import System.Data.Entity.Infrastructure and the namespace where your context lives):
So what this is really doing differently is provide a Lambda that can dig the ObjectContext out of your DbContext, instead of just passing the type to the context directly.
Hope this help someone else looking.
Marked as answer by sjnaughton on Jan 22, 2013 10:21 AM
sjnaughton
All-Star
27308 Points
5458 Posts
MVP
Re: VS2012 RTM - Context type is not supported with ASP.NET dynamic data
Nov 08, 2012 10:01 PM|LINK
Can you send me the schema? so I can replicate?
Always seeking an elegant solution.
mclayton
Member
32 Points
5 Posts
Re: VS2012 RTM - Context type is not supported with ASP.NET dynamic data
Nov 09, 2012 11:23 AM|LINK
I found the problem with my database was a database table named Site which was conflicting the default Site class.
mclayton
Member
32 Points
5 Posts
Re: VS2012 RTM - Context type is not supported with ASP.NET dynamic data
Nov 29, 2012 09:22 PM|LINK
sjnaughton I was able to find another way without having to delete the TT files or change Code Generation to Default.
Here is the Link: http://blog.davidebbo.com/2011/01/using-dynamic-data-with-ef-code-first.html
This is a direct copy of the portion that works:
Approach #1: dig the ObjectContext out of the DbContext
The workaround is quite simple. In your RegisterRoutes method in global.asax, just add the following code (you’ll need to import System.Data.Entity.Infrastructure and the namespace where your context lives):
<div> <div id="highlighter_809619" class="syntaxhighlighter plain"> <div class="toolbar">?</div>public static void RegisterRoutes(RouteCollection routes) {</div> <div class="line number2 index1 alt1">DefaultModel.RegisterContext(() => {</div> <div class="line number3 index2 alt2">return ((IObjectContextAdapter)new BlogContext()).ObjectContext;</div> <div class="line number4 index3 alt1">}, new ContextConfiguration() { ScaffoldAllTables = true });</div> </div>So what this is really doing differently is provide a Lambda that can dig the ObjectContext out of your DbContext, instead of just passing the type to the context directly.
Hope this help someone else looking.
dave000777
Member
12 Points
1 Post
Re: VS2012 RTM - Context type is not supported with ASP.NET dynamic data
Jan 19, 2013 07:45 PM|LINK
Had same issue, resolved by importing the namespace at top of global.asax
The namespace is defined in the Namespace property of the ConceptualEntityModel, i.e. your edmx file.
<%@ Import Namespace="AdventureWorksLT2012Model" %>
Now it works!
mszadig
Member
2 Points
1 Post
Re: VS2012 RTM - Context type is not supported with ASP.NET dynamic data
Apr 26, 2013 02:48 PM|LINK
I am experiencing the same problem using VS2012 update 1 and AdventureworksLT2012.
I followed the walkthrough at :http://msdn.microsoft.com/en-us/library/cc488469(v=vs.100).aspx
It was necessary to use:
DefaultModel.RegisterContext(() = { return ((IObjectContextAdapter)new AdventureWorksLT2012_DataEntities()).ObjectContext; },new ContextConfiguration() { ScaffoldAllTables = true });
However, just compiling with this will fail because IObjectContextAdapter is not defined.
I had to add: <%@ Import Namespace="System.Data.Entity.Infrastructure" %> to global.asax
thanks to: http://stackoverflow.com/questions/16146423/dynamic-data-iobjectcontextadapter-missing-reference
which had the answer in the most recent reply.
Following this, it finally compiled and worked, but this took a long time to dig out!