locked
Invalid Cast Exception - simple drilldown RRS feed

  • Question

  • User-1705348079 posted

    Hi,

     I tried duplicating Scott's video demo - build a Linq to SQL class to connect to Northwind (on my SQL 2005 server, not App_Data); modify Global.ASAX and run - I get the list of tables, but when I click on a table name, I get an Invalid Cast exception (System.InvalidCastException: Unable to cast object of type 'NWindLinqDataContext' to type 'System.Data.Objects.ObjectContext').

     Any idea what I'm doing wrong, or if my VS2008 is misconfigured?

     Thanks,

     EricF

    Tuesday, October 7, 2008 5:55 PM

Answers

  • User-330204900 posted

    Hi Eric, have alook at this http://code.msdn.microsoft.com/dynamicdata/WorkItem/View.aspx?WorkItemId=25 I think you may have started with the wrong DD project type.

    This is from Scott Hanselman...
    This looks like the using the wrong data model in the wrong project type. Note you have a Linq2SQL datacontext but the errors come from the EntityDataSource. There are two project templates for Dynamic Data: Dynamic Data and Dynamic Data Entites. For doing Linq2Sql models you need to use the Dynamic Data project. For doing EntityFramework models you need to use the Dynamic Data Entities. We have two different project types because the templates and pages are a little different based on which model type is used.

    Try creating a new project based on the Dynamic Data Website  or Dynamic Data Web Application not the ones with Entities in the name

    Hope this helps [:D]

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, October 7, 2008 6:02 PM

All replies

  • User-330204900 posted

    Hi Eric, have alook at this http://code.msdn.microsoft.com/dynamicdata/WorkItem/View.aspx?WorkItemId=25 I think you may have started with the wrong DD project type.

    This is from Scott Hanselman...
    This looks like the using the wrong data model in the wrong project type. Note you have a Linq2SQL datacontext but the errors come from the EntityDataSource. There are two project templates for Dynamic Data: Dynamic Data and Dynamic Data Entites. For doing Linq2Sql models you need to use the Dynamic Data project. For doing EntityFramework models you need to use the Dynamic Data Entities. We have two different project types because the templates and pages are a little different based on which model type is used.

    Try creating a new project based on the Dynamic Data Website  or Dynamic Data Web Application not the ones with Entities in the name

    Hope this helps [:D]

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, October 7, 2008 6:02 PM
  • User-1705348079 posted

    That's fixed it - thanks all (and Steve).

     

    -e

    Tuesday, October 14, 2008 3:53 PM