:SqlConnection에서 EF4 EntityConnection을 사용할 수 있습니까? 예를 들어
SqlConnection connection = new SqlConnection(efContext.Connection...?)
connection.Open();
etc..
:SqlConnection에서 EF4 EntityConnection을 사용할 수 있습니까? 예를 들어
SqlConnection connection = new SqlConnection(efContext.Connection...?)
connection.Open();
etc..
하지 직접, 아니,하지만 당신은 그것에서 SQL 연결 문자열을 얻을하고 StoreConnection
속성을 사용하여 새 연결을 만들 수 있습니다
SalesSyncEntities ctx = new SalesSyncEntities();
EntityConnection ec = (EntityConnection)ctx.Connection;
SqlConnection sc = (SqlConnection)ec.StoreConnection;
string adoConnStr = sc.ConnectionString;
return adoConnStr;
는 here 발견.
업 캐스팅 할 필요가 없으며 DbConnection에 'ConnectionString' 멤버가 있습니다. –
@Motton, 이것은 나를 위해 작동하지 않았다. DbConnection 개체 (위의 예제에서 ctx.Connection)의 ConnectionString 속성에는 "name = MyEntities"값만 있습니다. @Behrens가 보여준대로 트래버스해야했습니다. – sisdog
아니요, Entity Framework의 연결 문자열은 모델 파일과 기본 저장소 연결을 지정합니다. 이 형식은 SQL Server에서 이해할 수있는 형식이 아닙니다.
http://stackoverflow.com/questions/1576067/entity-framework-objectcontext-raw-sql-calls-to-native-dbms가 필요합니까? – a1ex07
@ a1ex07 그 질문은 이전 버전의 EF와 PostGres에 대한 질문이었습니다 ... – morganpdx