I need to regularly refresh my Linq To SQL classes; Yes, shame on me for not thinking about my data schema thoroughly enough, bad developer, ad nauseum. I found SQLMetal almost does the trick, but maybe I'm missing something from the parameter list.
When I run my batch file from my shiny new toolbar button using Visual Studio External Tools,
@echo off
del c:\path\to\LinqToSql.dbml
SQLMetal.exe /server:SERVER\SQLSERVER /database:db /timeout:0 /dbml:"c:\path\to\LinqToSql.dbml" /namespace:DAL /context:DataDataContext /entitybase:System.Data.Linq.DataContext /language:csharp /pluralize
SqlMetal generates the .dbml file, hooray. However, Question 1 can I programmatically include the .dbml file into my project?
Question 2
Why, when I compile after manually including the newly generated .dbml file, do each of my classes have the following build errors associated with the line number of their parameterless constructors? e.g. 30 tables = 30 build errors.
'System.Data.Linq.DataContext' does not contain a constructor that takes 0 arguments
The actual
I did notice my DataDataContext
generated class is without a parameterless constructor, so I added a partial class to supplement, but it still doesn't do the trick.
public partial class DataDataContext
{
public DataDataContext() :
base(global::DAL.Properties.Settings.Default.MyConnectionString, mappingSource)
{
OnCreated();
}
}
I thought this refresh process would be able to be automated, but manually adding the generated .dbml file that produces these constructor errors isn't working for me.