none
SQLMetal (LINQ) Class Generation Compilation Errors in IDE

    Question

  • Hello,

    I am trying to automatically generate a datacontext for my database schema, however when I use the SQLMetal application to generate the file, the file shows errors when I load it into the IDE.

    The following errors are generated in the majority but not all of the classes:

        Type 'System.Data.Linq.ChangeAction' is not defined.
        Type 'System.ComponentModel.INotifyPropertyChanging' is not defined. 
        Type 'System.Nullable' is not defined.

    I have read that this occurs from an incorrect installation of dotnet fx 3.5 where the system.dll is an incorrect version, I have reinstalled this and still get the same dll version (2.0.50727.3031) and errors.

    The number of tables in the database is over 200, and I wonder if this had anything to do with it as if I added them in through the IDE it appears to work up until a ceratin number of tables.

    If anybody could shed some light on this it would be most appreciated.

    Many Thanks,

    Brian

    Tuesday, July 15, 2008 12:55 PM

Answers

  • Hello,

     

    I have finally discovered the reason why these errors occurred and it is because one of the tables is named "System" which obviously conflicts with the system namespace and generated all the mentioned error messages.

     

    Changing the name of the class clears these errors.

     

    Brian

    Tuesday, July 29, 2008 11:51 AM

All replies

  •  Dejay2k wrote:

     Since you can't see System.Nullable, I suspect this is a bigger issue with this project than just LINQ. It almost sounds like you are trying to access it in VS 2003 which would target the 1.1 framework that doesn't have System.Nullable.

    If you are using VS 2008, check your references to System.Data.Linq, System.Core and MSCorLib to make sure they are pointing to the right versions. You may want to try creating a new project and importing the generated SQL Metal class file to see if it compliles there. If so, there is a problem with the references in your exisiting project.

    Jim Wooley
    www.ThinqLinq.com

     

    Hello,

     

    I've checked the references and everything appears to be accessing the correct versions.

     

    To try and diagnose this issue further I created a test database with 300 tables with primary and foreign key relationships between each table, and subsequently generated the DBML file using SqlMetal, which loaded into VS 2008 without any compilation issues.

     

    I then regenerated the DBML file based on our development database and subsequent loaded that into the same VS project, and the compilation errors were generated.

     

    The strange thing is that I get errors on some lines but not others which are identical in syntax, the first error is shown on line 5866 as below:

     

    Error 1 Type 'System.ComponentModel.INotifyPropertyChanging' is not defined. C:\Documents and Settings\My Documents\Visual Studio 2008\Projects\WindowsApplication5\WindowsApplication5\DEV35DEV.designer.vb 5866 13 WindowsApplication5

     

    Code Snippet

    5864 <Table(Name:="dbo.AccommodationContact")> _

    5865 Partial Public Class AccommodationContact

    5866 Implements System.ComponentModel.INotifyPropertyChanging, System.ComponentModel.INotifyPropertyChanged

     

    However, the table that preceeds it does not show the error which is very confusing:

     

    Code Snippet

    5665 <Table(Name:="dbo.AccommodationCompany")> _

    5666 Partial Public Class AccommodationCompany

    5667 Implements System.ComponentModel.INotifyPropertyChanging, System.ComponentModel.INotifyPropertyChanged

     

    VS suggests correcting the line with "Global.System.ComponentModel.INotifyPropertyChanging" and this actually resolves each issue; although we could do this we need to be able to automatically regenerate the file on a regular basis which is not possible if it then needs te be manually edited.

     

    Not sure if it is relevant but the file is over a 100,000 lines of code long and wondered maybe if that could be causing the problem?

     

    If it is of any use I can provide the dbml file to help (although I won't paste it here for obvious reasons)<>

     

    Many thanks for any help on this issue,

     

    Brian

    Wednesday, July 16, 2008 8:35 AM
  • Hello,

     

    I have finally discovered the reason why these errors occurred and it is because one of the tables is named "System" which obviously conflicts with the system namespace and generated all the mentioned error messages.

     

    Changing the name of the class clears these errors.

     

    Brian

    Tuesday, July 29, 2008 11:51 AM