简体   繁体   English

将先前生成的实体类与另一个数据库重用(相同的架构/表)

[英]Reusing previously generated entity classes with another database (same schema/tables)

I wrote a tool that queries/updates a database using Linq to SQL. 我写了一个使用Linq to SQL查询/更新数据库的工具。 The entity classes autogenerated by Visual Studio are bound to the name of this specific database copy. Visual Studio自动生成的实体类绑定到此特定数据库副本的名称。 It looks like if I need to rerun the tool on another copy of the same database (same table names, schema, etc) I need to create entity classes again for that database. 好像我需要在同一数据库的另一个副本(相同的表名,架构等)上重新运行该工具时,需要再次为该数据库创建实体类。 Is it possible to create one set of entity classes and have the rest of the program pass in the name of server/database as parameters when creating the data context? 创建数据上下文时,是否可以创建一组实体类并使程序的其余部分作为参数传递服务器/数据库的名称?

请使用此DataContext构造函数指定新的数据库连接字符串-DataContext构造函数

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM