엔티티 프레임워크 EntityConnection 문제는 메타데이터
-
15-09-2020 - |
문제
우리는 우리를 구축을 위해 노력하고 EntityConnection 동적으로 다른 사용자에 연결하는 전혀 다른 데이터베이스에서 결정을 지원합니다.이렇게하기 위해서 우리는 테스트 코드는 여기에서 찾을: http://msdn.microsoft.com/en-us/library/bb738533.aspx.우리가 구현한 이 아래:
' Specify the provider name, server and database.
Dim providerName As String = "System.Data.SqlClient"
Dim serverName As String = "OurDBServerName"
Dim databaseName As String = "OurDBName"
' Initialize the connection string builder for the
' underlying provider.
Dim sqlBuilder As New SqlConnectionStringBuilder
' Set the properties for the data source.
sqlBuilder.DataSource = serverName
sqlBuilder.InitialCatalog = databaseName
sqlBuilder.IntegratedSecurity = False
sqlBuilder.UserID = "OurAppUserName"
sqlBuilder.Password = "OurPassword"
' Build the SqlConnection connection string.
Dim providerString As String = sqlBuilder.ToString
' Initialize the EntityConnectionStringBuilder.
Dim entityBuilder As New EntityConnectionStringBuilder
'Set the provider name.
entityBuilder.Provider = providerName
' Set the provider-specific connection string.
entityBuilder.ProviderConnectionString = providerString
' Set the Metadata location to the current directory.
entityBuilder.Metadata = "res://*/NotaModel.csdl|" & _
"res://*/NotaModel.ssdl|" & _
"res://*/NotaModel.msl"
Console.WriteLine(entityBuilder.ToString)
Using conn As EntityConnection = New EntityConnection(entityBuilder.ToString)
conn.Open()
Console.WriteLine("Just testing the connection.")
conn.Close()
End Using
때 conn.Open()실행하는 오류가 발생합니다:"Unable to load 지정된 메타데이터 리소스입니다." 그것은 보인다는 것을 나타내는 하나 이상의"res://*..."참조은 잘못된 것입니다.내가 있는 것을 확인했 프로젝트가 실제로 이러한 파일을 포함하고 있(아래 bin/디버깅 폴더).우리는 무엇을 여기에-아이디어?
감사
해결책
Yes res://
부분은 잘못된 것입니다.보 리소스에 이름을 반사체(안을 어셈블리)지,로컬 파일 시스템,무엇을 보고 그들은 해야 합니다.
제휴하지 않습니다 StackOverflow