views:

101

answers:

3

Hi,

We just created a new field in a database table, and so deleted, and re-inserted the table in the LINQ Class. The new database field appears in the LINQ Class in the diagram. However, when we're using the field, we get an error that says the table does not contain a definition for the field.

Any ideas on how we can solve this? Thanks!

UPDATE: What steps are required to update the LINQ to SQL Class? Maybe we're doing something wrong.

UPDATE 2: Picture of our problem - LINQ - http://img99.imageshack.us/img99/6033/usertable.png | Code - http://img43.imageshack.us/img43/5145/linqerror.png

+1  A: 

Check the table def side of your mapping documents, either using properties in the designer, or by closing Studio and examining the XML. I recommend the designer.

Make sure the field name matches the field name in the database.
I've had problems with a few reserved keywords when using Linq2Entities, and I'd recommend you avoid reserved words in names (even though the [] handle them).

Russell Steen
I've done this before. also comparing them to the previous version in source control is sometimes useful.
RichardOD
+1  A: 

While this doesn't answer your question necessary, it may help to solve it - I've been a long time fan of the LINQ to SQL and Entities tools by Huagati. The re-sync aspect alone has saved me so much time, it's well worth the $50 (for the standard version) IMO.

http://www.huagati.com/dbmltools/

Hope it helps...

Edit:

In order to update the LINQ to SQL classes, you can either do it manually (bllurgh) or, you can remove them from the designer and drag-and-drop them from the Data Connections node in the Server Explorer.

Kieron
Looking into this.
stringo0
I'm not sure if this works for visual web developer - I emailed support.
stringo0
@stringo0 - if Visual Web Developer is one of the 'express edition' versions of Visual Studio then unfortunately those don't support add-ins... ...add-ins unfortunately require VS standard/pro/team...
KristoferA - Huagati.com
@Kieron thanks :)
KristoferA - Huagati.com
Hi, I'm getting the following error when trying to remove the table and re-add it - our new field doesn't seem to get recognized :[ :'dataClass.aspnet_User' does not contain a definition for 'Gender' and no extension method 'Gender' accepting a first argument of type 'dataClass.aspnet_User' could be found (are you missing a using directive or an assembly reference?)
stringo0
Have you tried removing it from the designer and re-adding it (ensuring that the field is actually available and ready on/ in the table)?
Kieron
A: 

I had to delete the entire LINQ Class, recreate it and re-add the tables for my problem to go away. Simply deleting a single table and re-adding it, or deleting all tables in the class and re-adding them did not work either.

stringo0