I am using SqlMetal for the general DataContext.dbml class for my ASP.net application using LinqToSql. When I originally created the DataContext.dbml file, Visual Studio used it to create the associated DataContext.designer.cs file. This constructor file contains the DataContext class in C #, which is used throughout the application (and derived from XML in the dbml file) and is important for bridging the gap between the SqlMetal output and using the DataContext with LinqToSql.
However, when I make changes to the database and recreate the dbml file, the constructor file is never restored on my website. Instead, the old constructor file is saved (and therefore, none of the changes to the DBML file are available through the DataContext LinqToSql class).
The only process that I have been able to use so far to restore the constructor file,
- Go to Windows Explorer and delete the dbml and designer.cs files.
- Go to Visual Studio and click Refresh in Solution Explorer. The dbml and designer.cs files now disappear from the project.
- Restore dbml file using SqlMetal
- Go to Visual Studio and click Refresh in Solution Explorer. Now the designer.cs file is recreated.
It appears that Visual Studio will only generate the designer.cs file when it detects a new dbml file that does not yet have the designer.cs file. This process is quite impractical because it involves several manual steps and a mess with source control.
Does anyone know how I can automatically restore the designer.cs file without having to perform the manual delete / update / restore / delete process described above?
source share