开发者

changes to datacontext and linq-to-sql data model

I'm building an asp application from the ground up using Linq-to-SQL as my ORM. I have a dbml file with a datacontext that includes all the tables开发者_开发问答 of the database (15 for now). If I make changes to the database, by adding a table, adding fields or by changing the data type of a field for instance, how are these kinds of change handled when they occur?

Do I simply drag and drop the new table on the ORM mapper and voila?

Thanks.


Have a look at How to update Linq to SQL dbml file? [best practice] there you will find your answer.


I prefer to use SqlMetal (via a bat file) to fully regenerate the DB schema.

However, you'll find that SqlMetal generates for the entire database. To remove certain tables or relationships; and/or to rename certain tables or generated properties you could look at my blog on filtering items generated by SqlMetal using Powershell.

However, you could of course do it all via the visual studio designer, but that's manual and annoying to repeat for a small change. Or you could manually deal with DBML but that is nasty.


The Visual Studio IDE transfer the changes you do to your dbml file to your ORM classes automatically.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜