0

SQL Server와 SQL CE4에 모두 연결되는 응용 프로그램을 개발하려고합니다. 내가 SQL 세륨 4.0 연결 문자열동적 SQL CE 4 연결 문자열 DbContext 여전히 오류가 발생했습니다

public partial class ModelContainer : DbContext 
{ 

    public ModelContainer() 
    { 

      SqlCeConnection con = new SqlCeConnection("Data Source=D:\\Charities.sdf"); 
      this.Database.Connection.ConnectionString = con.ConnectionString; 
      this.Database.Connection.Open();  
    } 
    public DbSet<Grant> Grants { get; set; } 
    public DbSet<GrantDetail> GrantDetails { get; set; }} 

을 관리 할 수있는 옵션을 생성하지만 난도록 SqlConnection과 같은 방법으로 다른 SQL 서버 연결을 만들 manged했던

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

여전히 오류가 발생하면 연결을 열려고 할 때 그것은 일했다. 그러나 이것은 실망한다!!

제안 사항?

좋습니다.

+0

데이터베이스의 암호 무엇입니까? 연결 문자열은 데이터 소스 = D : \\ Charities.sdf와 같아야합니다. 암호 = 'pwd' – Ehsan

+1

답장보기 : http://stackoverflow.com/questions/7905076/sqlserverce-defaultconnectionfactory – ErikEJ

+0

감사합니다. ErikEj : 여기에서 발견했습니다. http://stackoverflow.com/questions/12490190/ef -5-sql-ce-4-how-to-specify-custom-location-for-database-file 그것은 당신의 Idia와 같습니다. – Eiaddar

답변

0

here 에서 답 키 데이터베이스 클래스에서 Database.DefaultConnectionFactory 속성이

관련 문제