简体   繁体   中英

No Entity Framework Provider Found

i have a project that is been started two months ago ! i'm using [LASG]: https://layerguidance.codeplex.com/ Architecture for my Solution ! i'm working in my solution well since i have received the " No Entity Framwork provider found for the ADO.net Provider with invarient name 'System.Data.SqlClient' "

the application config file contain the full block of provider

this is my app.config file :

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="mssqllocaldb" />
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
  <connectionStrings>
    <add name="MASTERGESTION" connectionString="Data Source=ZZZZ\ZZZZZ;Initial Catalog=XXXXXX;User ID=YY;Password=ZZZZZZ" providerName="System.Data.SqlClient" />
  </connectionStrings>
</configuration>

I copied the project in other computer, after building the solution, it start normally and without provider error

I rebuild the solution many times, i re-add references manually with no response!

Any help please? i loose six hours for no reason

The defaultConnectionFactory shouldn't be:

System.Data.Entity.Infrastructure.LocalDbConnectionFactory 

Instead make it:

System.Data.Entity.Infrastructure.SqlConnectionFactory

I assume it worked on the second machine as that has LocalDb installed and the first one doesn't.

Try instead of

User ID=YY;Password=ZZZZZZ

to use

Integrate Security=True

also add in <context>

<context type="tablename, databasename">
        <databaseInitializer type="databasename.Migrations.tablenameInitializer, databasename" />
      </context>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM