We all know that Linq to SQL (and SQLmetal / exe) is indeed a “prototype” quality product (it lacks basic functions, such as updating the schema and detecting zero columns with a default value).
Is there a way to automatically create my .dbml (similar to LINQ to SQL or SQLmetal) And will it detect columns NOT NULLthat have a default value?
Requirements: it must be "simple" to create as linq-to-sql or sqlmetal.
Clarification of what I need for:
I have many tables with DateCreatedand fields DateModified, as well as some columns bitand enum-like ( int) with default values; all of which should be u NOT NULL.
I will need to update ("update") .dbml after making changes to the database ... so (re) setting Auto-Generate (or Auto Sync ) to Trueis not something I really need to do almost every time I updating the scheme.
The following code (based on handling defaults with LINQ to SQL ):
namespace Project.Data
{
public partial class ProjectDataContext
{
partial void OnCreated()
{
if (this.DateCreated == null)
{
this.DateCreated = DateTime.UtcNow;
}
}
}
}
not compiled (errors c ... does not contain a definition for 'DateCreated' ...). I really did not see the reasons why it should compile ... but I did it anyway. Perhaps I just do not understand the context of the code from his example.
source
share