Programing

키워드가 지원되지 않는 데이터 소스

lottogame 2020. 11. 11. 07:52
반응형

키워드가 지원되지 않는 데이터 소스


기본 멤버십 데이터베이스가있는 asp.net-mvc 응용 프로그램이 있습니다. ADO.NET Entity Framework에서 액세스하고 있습니다.

이제 IIS로 옮기고 싶지만 몇 가지 문제가 나타났습니다. SQL Server Management Studio를 설치하고 새 DB를 만들고 이전 .MDF 파일의 모든 데이터를 가져와야했습니다. 남은 일은 (내가 아는 한) 연결 문자열로 변경하는 것입니다. 그러나 나는 이것에 대해 실제로 경험하지 않았으며 지원되지 않는 키워드 '데이터 소스'를 계속 얻고 있습니다. 예외. 내 연결 문자열은 다음과 같습니다.

<add name="ASPNETDBEntities" 
     connectionString="Data Source=MONTGOMERY-DEV\SQLEXPRESS;Initial Catalog=ASPNETDB;Integrated Security=True;" 
     providerName="System.Data.EntityClient" />

어떤 아이디어라도, 무엇이 잘못 되었나요?


가지고있는 것은 유효한 ADO.NET 연결 문자열이지만 유효한 Entity Framework 연결 문자열이 아닙니다 .

EF 연결 문자열은 다음과 같습니다.

<connectionStrings> 
  <add name="NorthwindEntities" connectionString=
     "metadata=.\Northwind.csdl|.\Northwind.ssdl|.\Northwind.msl;
      provider=System.Data.SqlClient;
      provider connection string=&quot;Data Source=SERVER\SQL2000;Initial Catalog=Northwind;Integrated Security=True;MultipleActiveResultSets=False&quot;" 
      providerName="System.Data.EntityClient" /> 
</connectionStrings>

EF 연결 문자열의 모든 metadata=providerName=요소 가 누락되었습니다. 기본적으로 provider connection string부품에 포함 된 내용 만 있습니다 .

EDMX 디자이너를 사용하면 web.config 또는 app.config에서 유효한 EF 연결 문자열을 만들어야합니다.

마크

업데이트 : 좋아, 뭘 하려는지 이해합니다. ASP.NET 사용자 / 멤버십 데이터베이스에만 두 번째 "ADO.NET"연결 문자열이 필요합니다. 문자열은 정상이지만 providerName이 잘못되었습니다. "System.Data.SqlClient"여야합니다.이 연결은 ENtity Framework를 사용하지 않습니다. "EntityClient"를 지정하지 마십시오!

<add name="ASPNETMembership" 
     connectionString="Data Source=MONTGOMERY-DEV\SQLEXPRESS;Initial Catalog=ASPNETDB;Integrated Security=True;" 
     providerName="System.Data.SqlClient" />

providerName=System.Data.EntityClient==> Entity Framework 연결 문자열 을 지정하는 경우 (메타 데이터 = 및 모든 항목 포함).

필요한 경우 providerName=System.Data.SqlClient==> 모든 EF 추가없이 직선 ADO.NET SQL Server 연결 문자열을 지정합니다.


이 문제는 색인별로 web.config (또는 app.config) 연결 문자열을 참조 할 때 발생할 수 있습니다.

var con = ConfigurationManager.ConnectionStrings[0].ConnectionString;

0 기반 연결 문자열은 기본적으로 스택의 상위에서 다른 항목을 상속 하므로 구성 파일의 연결 문자열이 항상있는 것은 아닙니다 .

권장되는 접근 방식은 이름으로 연결에 액세스하는 것입니다.

var con = ConfigurationManager.ConnectionStrings["MyConnection"].ConnectionString;

또는 먼저 구성 파일에서 connnectionStrings 요소를 지우려면 ...

<connectionStrings>
    <clear/>
    <add name="MyConnection" connectionString="...

나는 같은 문제를 겪고 있었다.
하지만이 코드는 잘 작동합니다.

<add name="MyCon" connectionString="Server=****;initial catalog=PortalDb;user id=**;password=**;MultipleActiveResultSets=True;" providerName="System.Data.SqlClient" />

Entity Framework를 사용하기 시작했을 때이 문제가 있었는데, 이전 SQL 서버 연결을 EntityFrameWork 연결로 변경하지 않았을 때 발생했습니다.

Solution: in the file where connection is made through web.config file "add name="Entities" connectionString=XYZ", make sure you are referring to the correct connection, in my case I had to do this

        public static string MyEntityFrameworkConnection
    {
        get
        {
             return ConfigurationManager.ConnectionStrings["Entities"].ConnectionString;
        }

    }

call MyEntityFrameworkConnection whenever connection need to be established.

private string strConnection= Library.DataAccessLayer.DBfile.AdoSomething.MyEntityFrameworkConnection;

note: the connection in web.config file will be generated automatically when adding Entity model to the solution.


I know this is an old post but I got the same error recently so for what it's worth, here's another solution:

This is usually a connection string error, please check the format of your connection string, you can look up 'entity framework connectionstring' or follow the suggestions above.

However, in my case my connection string was fine and the error was caused by something completely different so I hope this helps someone:

  1. First I had an EDMX error: there was a new database table in the EDMX and the table did not exist in my database (funny thing is the error the error was not very obvious because it was not shown in my EDMX or output window, instead it was tucked away in visual studio in the 'Error List' window under the 'Warnings'). I resolved this error by adding the missing table to my database. But, I was actually busy trying to add a stored procedure and still getting the 'datasource' error so see below how i resolved it:

  2. Stored procedure error: I was trying to add a stored procedure and everytime I added it via the EDMX design window I got a 'datasource' error. The solution was to add the stored procedure as blank (I kept the stored proc name and declaration but deleted the contents of the stored proc and replaced it with 'select 1' and retried adding it to the EDMX). It worked! Presumably EF didn't like something inside my stored proc. Once I'd added the proc to EF I was then able to update the contents of the proc on my database to what I wanted it to be and it works, 'datasource' error resolved.

weirdness


I was getting the same error, then updated my connection string as below,

<add name="EmployeeContext" connectionString="data source=*****;initial catalog=EmployeeDB;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework" providerName="System.Data.SqlClient" />

Try this it will solve your issue.

참고URL : https://stackoverflow.com/questions/1404268/keyword-not-supported-data-source

반응형