Given this object model variable:
DataBaseEntities db = new DataBaseEntities ();
The following code cannot be used from the db varibale connection string
SqlBulkCopy sbc = new SqlBulkCopy(db.Connection.ConnectionString);
try with this approach:
private string GetADOConnectionString() { var db = new DataBaseEntities(); EntityConnection ec = (EntityConnection)db.Connection; return ec.StoreConnection.ConnectionString; }
I found this here: Getting SqlConnection from EntityConnection
also see here: EntityConnection.StoreConnection Property
Edit: of course, this should be adapted, and you should check for zeros or check before casting ... this is just an example; -)
Dim objEntities As New DBEntities
I have a connection string already installed in the .edmx file in my project.