I used SQLMetal to generate a code file representing my database, and i can't figure out how to add entries to the database from the SQLMetal generated classes. How do i do this? do i just add to the various properties or something?
Asked
Active
Viewed 678 times
1
-
1It is pretty vague whether you mean "add rows" vs "add properties"... – Marc Gravell Aug 30 '09 at 07:22
2 Answers
1
The generated classes are partial classes, so you can extend them anywhere else in your assembly with another partial class definition (note: I don't mean extension methods, just another partial class declaration).
That way, you can also re-generate those classes without worrying of overwriting your other extensions of the classes.

Alex
- 75,813
- 86
- 255
- 348
1
Here's a good overview of linq-to-sql, which includes how to add to your database via the auto-generated classes (from SQL Metal). Link
Essentially:
- Create your database context object
- Create a new object (which was auto-generated)
- Populate your object's properties
- Add your object to the correct collection within your database context
- Submit changes to your database context. Voila!

Mark Carpenter
- 17,445
- 22
- 96
- 149