Deploy a LINQ to SQL Library using different SQL users

人盡茶涼 提交于 2019-12-11 07:47:35

问题


Thanks to this website I succeed to use a connectionString localized inside a web.config instead of the one provided in the app.config of the library. But my production and my test SQL Server do not have the same SQL user name.

Table(Name="SqlUserName.tableName")]
public partial class tableName : INotifyPropertyChanging, INotifyPropertyChanged
{
    ...
}

When I remove by hand the user name before the table name, it's working. But I still have to problems:

  1. Is it good to do that? Maybe there is a potential flaw I'm not aware of.
  2. If it's a good behavior how can I configure it somewhere? Each time that LINQ will regenerate the dbml, I will loose my modification. I think I can't move it to a partial class as it's an attribute and can't be redefined (I don't want to do it for all the tables also).

Thanks for your help.


回答1:


Use same name for connection strings in web.config local and remote server but use different username and password for them.

I follow this practice and it is perfectly for me.




回答2:


Finally I used the dbo schema for all the tables I created, this way I removed the dependency on the user and LINQ could generate the DBML again without breaking the deployment:

Table(Name="dbo.tableName")]
public partial class tableName : INotifyPropertyChanging, INotifyPropertyChanged
{
    ...
}


来源:https://stackoverflow.com/questions/688819/deploy-a-linq-to-sql-library-using-different-sql-users

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!