Click here to Skip to main content
15,905,963 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

When i test my service (for the first time), i get the following exception:
C#
System.Configuration.ConfigurationErrorsException was unhandled by user code
  HResult=-2146232062
  Message=Failed to find or load the registered .Net Framework Data Provider.
  Source=System.Data
  BareMessage=Failed to find or load the registered .Net Framework Data Provider.
  Line=0
  StackTrace:
       at System.Data.Common.DbProviderFactories.GetFactory(DataRow providerRow)
       at System.Data.EntityClient.EntityConnection.GetFactory(String providerString)
       at System.Data.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString)
       at System.Data.Objects.ObjectContext..ctor(String connectionString, String defaultContainerName)
       at ExamGeneratorDataModel.ExamEntities..ctor() in d:\my documents\visual studio 2010\Projects\examgenerator\ExamGeneratorDataModel\ExamGeneratorModel.Designer.cs:line 46
       at examgenerator.UserService.GetUser(String userName) in d:\my documents\visual studio 2010\Projects\examgenerator\examgenerator\UserService.cs:line 31
       at examgenerator.UserService.Login(String userName, String password) in d:\my documents\visual studio 2010\Projects\examgenerator\examgenerator\UserService.cs:line 19
       at SyncInvokeLogin(Object , Object[] , Object[] )
       at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
       at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
  InnerException: 


In my app file, i have added a connection strings attribute as such from my data mode:

XML
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <connectionStrings>
    <add name="ExamEntities" connectionString="metadata=res://*/ExamGeneratorModel.csdl|res://*/ExamGeneratorModel.ssdl|res://*/ExamGeneratorModel.msl;provider=MySql.Data.MySqlClient;provider connection string=&quot;server=localhost;User Id=root;password=0000;Persist Security Info=True;database=exam&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>
  <system.web>
    <compilation debug="true" />
  </system.web>
..
..
..


The error is thrown an i am transfered to this code:

C#
public ExamEntities() : base("name=ExamEntities", "ExamEntities")
       {
           this.ContextOptions.LazyLoadingEnabled = true;
           OnContextCreated();
       }


I have tried googling and even re-reading John Sharp's Windows Communication Foundation 4 Step by Step and i have not found what could be wrong with here :-( . I even turned off my anti-virus (what?.. I was very desperate) :-)
Posted

1 solution

Found the solution. I had not added:

using MySql.Data.MySqlClient;


Do not blame me. We have all done that. ALL! ;-)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900