Error using dynamic data website in VS2012

I decided to use the Dynamic Data Entities website in VS2012.

So, I created this website and then added the App_Code directory and added a new edmx to it and named it myDB.edmx . After that, I uncommented the line of code in Global.asax that registers the entity context:

 DefaultModel.RegisterContext(typeof(myDBEntities), new ContextConfiguration() { ScaffoldAllTables = true }); 

But when I start the site, this error occurs:

 The context type 'myDBEntities' is not supported. 

how can i fix this?

ps: Now you have some differences between using L2S ​​on the Dynamic Data L2S Web Site and using the Entity Framework on the Dynamic Data Entities Web Site .

+4
source share
4 answers

I am still looking for a reason, but now the only option is to create a project in VS2010, and then transfer the project to VS2012, and then I have no problems starting the application

+5
source

This problem occurs because in Visual Studio 2012 you get DbContext (instead of ObjectContext , as in Visual Studio 2010), the code generated by default for all new models created using EF Designer. To solve the problem, you need to return to generating the ObjectContext code.

For more information, see Returning to an ObjectContext in EF Designer .

+2
source
  • Delete TT files from the model

  • Change "Becoming Code" to "Default"

0
source

Inside the Global.asax file, uncomment the other RegisterContext line.

  DefaultModel.RegisterContext( _ New System.Func(Of Object)(Function() DirectCast(New [Your edmx](), IObjectContextAdapter).ObjectContext), _ New ContextConfiguration() With {.ScaffoldAllTables = True} _ ) 
0
source

Source: https://habr.com/ru/post/1437763/


All Articles