INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Struggling to even get DynamicData example working!

Struggling to even get DynamicData example working!

(OP)
I have followed the Walkthrough: Creating a New ASP.NET Dynamic Data Web Site Using Scaffolding (http://msdn.microsoft.com/en-us/library/cc488469%2...)

I have created the Dynamic Data website in Visual Studio Express 2012 without problems.

I have created the database model using the Entity Framework without problems.

I have added data using the AdventureWorks.dbml as suggested in the tutorial etc,

Where I am stuck is registering the data model for use by Dynamic Data! In the Global.asax file I have located the commented section that contains RegisterRoutes method, but no matter how hard I cross my fingers, I cannot get the thing working.

CODE -->

Public Shared Sub RegisterRoutes(ByVal routes As RouteCollection)
    '                     IMPORTANT: DATA MODEL REGISTRATION 
    ' Uncomment this line to register an ADO.NET Entity Framework model for ASP.NET Dynamic Data.
    ' Set ScaffoldAllTables = true only if you are sure that you want all tables in the
    ' data model to support a scaffold (i.e. templates) view. To control scaffolding for
    ' individual tables, create a partial class for the table and apply the
    ' <ScaffoldTable(true)> attribute to the partial class.
    ' Note: Make sure that you change "YourDataContextType" to the name of the data context
    ' class in your application.
    ' See http://go.microsoft.com/fwlink/?LinkId=257395 for more information on how to register Entity Data Model with Dynamic Data
        Model.RegisterContext(GetType(AdventureWorksLT_DataModel.AdventureWorksLT_DataEntities), _
    New ContextConfiguration() With {.ScaffoldAllTables = True})
        '  DefaultModel.RegisterContext( _
        'New System.Func(Of Object)(Function() DirectCast(New YourDataContextType(), IObjectContextAdapter).ObjectContext), _
        '  New ContextConfiguration() With {.ScaffoldAllTables = False} _
        ') 
I noticed that I was using AdventureWorks2012 not the AdventureWorksLT version fo the database so changed the string to:

CODE -->

Model.RegisterContext(GetType(AdventureWorks2012_DataModel.AdventureWorks2012_DataEntities), _
    New ContextConfiguration() With {.ScaffoldAllTables = True}) 

I have no idea what I have or have not done, but it seems unrealistically difficult for a novice to even get started? Can anyone help me get this thing configured so I can at least start to learn how to use it?





RE: Struggling to even get DynamicData example working!

(OP)
I have started several times from scratch.

I have been able to set up a Dynamic Data Website, attach a database (NORTHWND.mdf on (LocalDB\v11.0) ), create a Linq to SQL class and change the Global.asax file so that the default.aspx loads with the list of tables.

CODE -->

DefaultModel.RegisterContext(GetType(NorthwndDataContext), New ContextConfiguration() With {.ScaffoldAllTables = True}) 

When I click on a table, this error pops up!

"Unable to cast object of type 'NorthwndDataContext' to type 'System.Data.Objects.ObjectContext'."

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close