It's not suggested to change the generated file directly as it will be regenerated and overwrite your changes if you edit the DBML. The generated classes will be declared as
partial so you can change them by creating another file and declaring a
partial class with the same name and adding your changes there.
You can also add a common base class for your entities where you implement your custom code, but the Linq to Sql visual editor doesn't support it so you must edit your .dbml file manually.
In visual studio you can right-click the .dbml file in the solution explorer, select Open With, and then Xml Editor.
Now you can add the
EntityBase attribute to the
<Database> tag. The EntityBase attribute should contain the name of your common base class.
Finally you should right-click the .dbml file in the solution explorer and select Run Custom Tool. This will recreate your entity classes with the common base class.
- Editing the LINQ to SQL object model
- How to code the partial extensions that Linq to SQL autogenerates?
- Determine the source DataContext for a Linq to Sql query
- Linq to SQL intellisense has no knowledge of tables within the datacontext object
- Linq to sql as object data source - designer problem with partial classes
- Is there a secret to using LINQ to SQL to add records when the object has relationships?
- Is LINQ to SQL the best way to build a Model or create my own classes
- convert linq to object query to sql query (no linq to sql code or datacontext)
- Object Oriented Model on top of LINQ to SQL
- Getting the field names from a Linq To Sql object
- LINQ entity data model generated code error - The type 'DBContexts.Category' already contains a definition for 'ID'
- What SQL query or LINQ code would get the following data?
- Linq code to get the index of an object in an array from an object within a list
- MVC C# binding a linq to sql object with a one to many relation for the edit page
- Linq Help need to convert to Linq Object model from sql model
- Does Linq in Entity Framework code first use SQL or does it get the whole table first?
- My Linq to Sql Insert code seems to work fine but I don't get a record in the database
- Linq to sql order by a string that is not a property of the object
- Converting SQL query result to Linq result with an new field that is not in the Model
- Check Nullable for object insde LinQ to Sql code
- Concatenating the contents of a joined table and project into a view model in LINQ to SQL
- nullable object must have a value error in linq to sql in vb.net code
- Code equivalent to the 'let' keyword in chained LINQ extension method calls
- How can I get LINQ to return the object which has the max value for a given property?
- What is the linq equivalent to the SQL IN operator
- How are people unit testing code that uses Linq to SQL
- LINQ - Does the Where expression return new instance or reference to object instance
- LINQ to SQL: GroupBy() and Max() to get the object with latest date
- Iterate through properties and values of an object returned via a linq query on a domain model
- What is the easiest way to find the LINQ statement for a SQL statement
More Query from same tag
- Exclude null values while summation by specific column in a left joined table using LINQ
- How to get the last element of a Collection Navigation property
- Printing out the results of my linq query
- Strange Exception thrown using Dynamic Linq Entity Framework Query
- LINQ to SQL, select targets with max date
- c# Append XDocument Before Saving to File
- Define last index of element in text with linq
- Linq to sql - DateTime to Time
- Sequence contains no matching element
- Remove items from List<string> that exist in Substring of CheckedListBox items
- Linq to Entities Group By DateTime
- Postgres - Geospatial Search in LINQ or SQL with PostGis
- OrderBy(propertyName) for complex types
- How can I convert this console mongodb query to a C# mongo driver v2 one?
- Manually creating Lambda expression to use as where predicate
- Negating a method call in an Expression tree
- Linq merging two classes into a third?
- Rationale behind renaming of higher order list operations
- Find dead nodes from Parent Child Node collection
- Linq to get data from a table but not if in another table?
- How to alter this class object property text search so class does not need to be hardcoded
- When is a long line just too long?
- Linq expressions with Linq to Entities
- Format Data using Linq
- How does RavenDb "In" operator work?
- ApplyPropertyChanges and References
- Force convert DateTimeOffset to Nullable<DateTimeOffset>
- Using XmlReader to get all elements of a XML document (streaming)
- Difference Of Dates in Linq To Entities
- Compare two List<POCO> to find differences being case insensitive