Search code examples
linq-to-sqlvisual-studio-expressvisual-web-developerauto-generate

Visual Web Developer 2008 won't auto generate classes from Linq


I'm new to Linq and Visual web developer 2008 Express. I have read some posts here and Scott Guthrie's on setting up Linq, but I'm a little stuck because the classes aren't auto-generating as I thought they would. I have setup a database with a simple table (with the Primary Key as the ID, and it is set to auto-increment) plus a few other columns, and dragged and dropped it on to the DBML Linq designer pane. The table appears in the window, but no classes are auto-generated. When I right click on the table and select "View Code", DataClasses.cs is displayed, but I only see a partial class with no methods or properties.

Isn't Linq supposed to do this, or have I (quite likely) missed the point completely? Or is this functionality not available in Visual Web Developer 2008 Express?


Solution

  • No, you're not missing anything. That is exactly how it should work. Go to solution explorer, expand the dbml, and double-click on whatever.designer.cs. Down at the bottom, you'll see ...

    [Table(Name="dbo.YourTable")]
    public partial class YourTable: INotifyPropertyChanging, INotifyPropertyChanged
    {
    
        private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
    

    ... and all of your properties.