数据库架构更改后更新LINQ to SQL类最佳途径架构、途径、数据库、LINQ

2023-09-02 01:28:44 作者:占你心房i

我使用LINQ to SQL类项目中,其中数据库的设计还是有些变动的。

I'm using LINQ to SQL classes in a project where the database design is still in a bit of flux.

是否与该模式同步类的一个简单的方法,或是否需要手动更新的类,如果表设计更改?

Is there an easy way of synchronising the classes with the schema, or do I need to manually update the classes if a table design changes?

推荐答案

您可以使用SQLMetal.exe生成您的dbml和或CS / VB文件。使用pre-构建脚本来启动和目标在您的DataContext项目属于该目录。

You can use SQLMetal.exe to generate your dbml and or cs/vb file. Use a pre-build script to start it and target the directory where your datacontext project belongs.

C:Program FilesMicrosoft SDKsWindowsv6.0ABinx64sqlmetal.exe 
  /server:<SERVER> 
  /database:<database> 
  /code:"pathSolutionDataContextProjectdbContext.cs" 
  /language:csharp 
  /namespace:<your namespace>