I have a dbml file which I have added a couple of tables to. The database also contains synonyms which point to other tables in a different database. I can't seem to drag the synonyms to the design surface though?
as long as you have links with grants set up for your user and they're both on the same server you should be able to use a view (as Anas has correctly posted already) and drop that into the dbml.
I didn't think of using a view, i've tended to shy away from them over the years! I don't need to do any updating, so I don't have to write any stored procs.
I wonder is Visual Studio 2010 will allow you add Synonyms?
You should.I think it's not even a good idea to use Database Synonyms directly in your code because as you may know, sysnomy names and other stuff may changed during deployment.I would suggest to keep them referenced in your dv Views or SPs and not in your
code.
Hence, using the DB View will be a good idea here, not just because it's a workaround , but using Db Views will also remove the direct dependencies between your code and the Database Synonyms.
NiceYellowEg...
Member
19 Points
24 Posts
Add Synonym to .dbml file?
Apr 22, 2010 11:00 AM|LINK
Hi,
I have a dbml file which I have added a couple of tables to. The database also contains synonyms which point to other tables in a different database. I can't seem to drag the synonyms to the design surface though?
Please help!
Thanks
datacontext linqDataSource
MARK AS ANSWER if post helps :)
anas
All-Star
73649 Points
7914 Posts
Moderator
Re: Add Synonym to .dbml file?
Apr 24, 2010 12:20 PM|LINK
It seems that there is no support for them.
I suggest to create a db view that returns all the data from the sysnonym.Then you can add the new db view to te dbml model.
Since the db view is readonly, incase you want to modify synonym data, you can create stored procedures to accomplish such a task.
PeteNet
All-Star
81342 Points
11398 Posts
Re: Add Synonym to .dbml file?
Apr 24, 2010 05:19 PM|LINK
as long as you have links with grants set up for your user and they're both on the same server you should be able to use a view (as Anas has correctly posted already) and drop that into the dbml.
Peter
NiceYellowEg...
Member
19 Points
24 Posts
Re: Add Synonym to .dbml file?
Apr 26, 2010 08:51 AM|LINK
Thanks,
I didn't think of using a view, i've tended to shy away from them over the years! I don't need to do any updating, so I don't have to write any stored procs.
I wonder is Visual Studio 2010 will allow you add Synonyms?
MARK AS ANSWER if post helps :)
anas
All-Star
73649 Points
7914 Posts
Moderator
Re: Add Synonym to .dbml file?
Apr 26, 2010 11:29 AM|LINK
You should.I think it's not even a good idea to use Database Synonyms directly in your code because as you may know, sysnomy names and other stuff may changed during deployment.I would suggest to keep them referenced in your dv Views or SPs and not in your code.
Hence, using the DB View will be a good idea here, not just because it's a workaround , but using Db Views will also remove the direct dependencies between your code and the Database Synonyms.