본문 바로가기
MySql

MySQL Entity Framework 4 및 코드 우선 개발 CTP와 함께 MySql 사용

by 베이스 공부 2020. 11. 17.
반응형


<connectionStrings>
    <add name="NerdDinners"
         connectionString="Server=localhost; Database=NerdDinners; Uid=root; Pwd=;"
         providerName="MySql.Data.MySqlClient"/>
  </connectionStrings>
  <system.data>
    <DbProviderFactories>
      <add name="MySQL Data Provider" 
           invariant="MySql.Data.MySqlClient" 
           description=".Net Framework Data Provider for MySQL" 
           type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.2.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
    </DbProviderFactories>
  </system.data>

튜토리얼과 마찬가지로 EF4가 자동으로 db를 생성 할 것으로 예상합니다. 대신 NerdDinners 데이터베이스가 존재하지 않는다고 불평하는 내부 예외와 함께 ProviderIncompatibleException을 발생시킵니다.

그럴 수 있지; 나는 일이 작동하는지 확인하기 위해 MySql db를 만들고 대신 다른 ProviderIncompatibleException을 얻었습니다. 이번에는 "DatabaseExists는 공급자가 지원하지 않습니다."

나는 Entity Framework를 실제로 탐구하는 것은 이번이 처음이며 (대부분 Linq to Sql을 고수했습니다), 이것은 모두 지난주에 출시 된 Code-First CTP에서 실행됩니다. 즉, 내가 여기서 잘못하고있는 것이 있습니까? 아니면 해결할 수있는 알려진 문제가 있습니까?

 

해결 방법

 

좋아, 마침내 몇 가지 관심 지점에서 작동했습니다.

대체로 긴 길이지만 결국에는

**최신 정보 Another point to note, when deploying your MVC site using MySQL you will most like need also add a DataFactory to your web.config. Usually because of the difference in MySql connectors out there and the versions of MySQL that are supported. (answer found through other sources after much head scratching) 다음을 추가하십시오.

  <system.data> 
    <DbProviderFactories> 
      <add name="MySQL Data Provider"
           invariant="MySql.Data.MySqlClient"
           description=".Net Framework Data Provider for MySQL"
           type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.3.6.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" /> 
    </DbProviderFactories> 
  </system.data>

web.config에 대한 별도 섹션으로 사이트와 함께 배포하는 MySQL.Data.dll의 버전 번호를 설정 합니다 (MySQL DLL을 "로컬로 복사"하는 것도 좋은 방법입니다. 호환성을 보장합니다.

 

참조 페이지 https://stackoverflow.com/questions/3283820

 

 

반응형

댓글