Pages

Monday 16 February 2015

Issues when creating a ASP.NET Dynamic data web application using C# with Entity Framework 6.0 ?

What is ASP.NET Dynamic Data?
Visual studio web application/website project that generates code for CRUD operations [Create, Read, Update, Delete] along with dynamic creation of UI for to display or edit the database information. Clubbing entity framework and ASP.NET  routing helps the dynamic data application to create dynamic URLs for screens. This makes life easier for developers to create a data driven website in few minutes without any hassles.

For more information of ASP.NET Dynamic Data, please refer MSDN - ASP.NET Dynamic Data

Blocker:
ASP.NET Dynamic Data Entities web application project do not work with Entity framework 6.0 in Visual studio 2013.
Issues:
  1. Missing namespaces
  2. Cannot convert lambda expression to type system.web.dynamicdata.modelproviders
  3. iobjectcontextadapter could not be found
  4. JavaScript runtime error: ASP.NET Ajax client-side framework failed to load.

Steps to cross the hurdles and run the application successfully,

  1. Create a ASP.NET Dynamic Data Entities web application project
  2. Refer the Entity Framework 6.0 NuGet Package
  3. Search for EFProvider NuGet and refer the same
  4. Add the entity model and configure the database with entity model
  5. Add the below code snippet in Global.asax file in register routes method,
    1. DefaultModel.RegisterContext(new Microsoft.AspNet.DynamicData.ModelProviders.EFDataModelProvider(() => new TP_WORKINGEntities()),new ContextConfiguration {ScaffoldAllTables = true});
  6. Build and Run the application
  7. You may get JavaScript Runtime error if yes, Please add the below code snippet in Global.asax file in register routes method
    1. routes.Ignore("{resource}.axd/{*pathInfo}");
  8. Now ASP.NET Dynamic Data web application should run fine without any issues