How to link VS2010 Database and LINQ to SQL project

As I work with new database projects in VS2010, and as I learn LINQ to SQL, I am wondering what is the best way to link the two groups of information so that when updated, other updates go along with it.

From my research here at SO as well as Google, the general rule is "Create a database and then create LINQ to SQL classes". Of course, if I make changes to my database, LINQ to SQL is not automatically updated and I have to do it manually. This is pretty straightforward now since my database is small, but I'm curious if there is an easier way to do this.

Also, LINQ to SQL tool is pretty good. The ability to create tables, add associations, and even create inheritance is very easy. As my second question, I'm curious if VS2010 can work in a different way - I design the database in a DBLM file and then link it to my database project.

I appreciate any help on any of these two questions. I am very interested in making this as simple as possible in order to reduce errors during development and improve the speed at which changes can be made.

+2


a source to share


1 answer


Jason. We've built a mission-critical L2S-based application platform for our solar business. I was primarily responsible for creating the internal data access layer. I used to realize that maintaining .DBML would be a huge pain in the background. Every time you add / update / delete objects in the schema, the DBML must be updated. And this is not always easy to do. My solution was to create my own code generator that generates our L2S classes, application layer classes (light version of L2S classes) and all logic / DAL code. This way, every time we make a schema change, we just run the code generator and everything is created for us.



I really like L2S, but without our custom code generator, I think I would pull out all of my hair. Also, it looks like sometimes the generated classes from .DBML are just plain wrong.

0


a source







All Articles