Thursday, September 29, 2011

Linq Error - Specified cast is not valid

I was getting this error in the selecting event.  The problem was that for whatever reason, a field in the the LinqToSql file had a different datatype from the actual table in the database.  The field in the table was of type bigint while the same field in the datacontext was of type int.  This could have happened if for example the database schema was altered after having dropped the table in the LinqToSQL file.  Removing the table from the datacontext and re-dropping it solved the issue.

Anyone know how to refresh the LinqToSQL file without having to remove the table and reinserting it?  That would be great!

2 comments:

  1. I think you can update the definitions from visual studio 2010. Just right click in the LINQ diagram and click on update.

    PS: you're a commercial organisation now? :P

    ReplyDelete
  2. Packers and Movers Bangalore - Reliable and Verified Household Shifting Service Providers Give Reasonable ###Packers and Movers Charges. Cheap and Best Office Relocation Compare Quotation for Assurance for Local and Domestic House Shifting and Get estimates today to save upto 20%, ***Read Customer Reviews - @ Packers And Movers Bangalore

    ReplyDelete