I've recently been looking into using EF in my .Net pages but I'm struggling a little when trying to access the public databases that are set up.
So for example in my Oracle SQL developer I would access a public database like this
SELECT name FROM users@publicserver
I'm trying to use this in the following way
Using myEntities As New TestEntities()
Dim allNames = From name In myEntities.users@publicserver
Select name
GridView1.DataSource = allNames
GridView1.DataBind()
End Using
Obviously this doesn't work as my EF doesn't contain the public server table as I'm not sure how to even add this to the EF (if that makes sense?)
I'm interested to know if it is possible to achieve this and if not does anyone have any ideas on the best method of accessing this?
EDIT
Ideally I'd like to be able to use LINQ with my Public database links if this is possible?
Have you tried using Synonyms?
CREATE SYNONYM [dbo].[MyTable] FOR [AnotherDatabase].dbo.[MyTable]
And then you could write:
SELECT name FROM MyTable
Synonyms work, but they are not automatically detected for reverse engineering, so you will need to manually edit the .edmx file to make them work. Here is how to do it.
Another option is to go for the Code First approach, and use the [Table] annotation, and just plain write the name of the synonym instead of the name of a table
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With