Ahhh, I ran into the same problem, and I actually solved it by doing this. In a module, I pass the dbLocation and dbPassowrd..
Public _db As yourEnt
Private _dbLocation As String
Public Property dbLocation() As String
Get
Return _dbLocation
End Get
Set(ByVal value As String)
_dbLocation = value
End Set
End Property
Private _dbPassword As String
Public Property dbPassword() As String
Get
Return _dbPassword
End Get
Set(ByVal value As String)
_dbPassword = value
End Set
End Property
I of course do some testing to ensure the database file does exist with file.io functions because if it doesnt, a blank db will be created automatically generating no errors but containing no information :-/. Played with that issue for a bit before i figured out what was going wrong.
Then you are going to create a new function in this module that is going to rebuild the connection string for the entities model, so that you do not need to use the app.config call.
Public Function dbConn() As String
If Not (dbLocation Is Nothing) And Not (fileExists(dbLocation)) Then
MsgBox("There is an error in your database configuration!")
Return Nothing
End If
Dim connectionString As String = New System.Data.EntityClient.EntityConnectionStringBuilder() _
With { _
.Metadata = "res://*/<entName>.csdl|res://*/<same>.ssdl|res://*/<same>.msl", _
.Provider = "System.Data.SQLite", _
.ProviderConnectionString = New System.Data.SqlClient.SqlConnectionStringBuilder() With _
{ _
.DataSource = dbLocation, _
.Password = dbPassword _
}.ConnectionString _
}.ConnectionString
Return connectionString
End Function
In that function you can see I check to make sure that the dbLocation is actually set and also that windows finds it before i create the connection string. If you see errors like table not found, then you probobly are creating a blank db project.
Now in your edmx designer file, at the top you will see where it is pulling out the info needed for the connection.
Partial Public Class yourEntitie
Inherits Global.System.Data.Objects.ObjectContext
Public Sub New()
MyBase.New("name=yourEnt", "yourEnt")
Me.OnContextCreated
End Sub
And you are going to make a simple change and instead of "name=yourEnt" you are going to refer to your connection builder..
Public Sub New()
MyBase.New(dbConn, "yourEnt")
Me.OnContextCreated
End Sub
And that does it I think, although it is late, and I am new to this programming thing so...
But if you have any questions please let me know, I will help as much as I can.