2

I am currently developing a project in MVC3 Visual Studio 2012. I am connecting to an external database but when I try to add a new controller I get this error.

Unable to retrieve metadata for 'Project.Models.Class'. Unable to find the requested .Net Framework Data Provider. It may not be installed.

I cannot figure out why it can't find my .Net Framework Data provider. I have altered the two machine.config files I can find, and they now look like this.:

<system.data>
    <DbProviderFactories>
    <add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
    <add name="Oracle Data Provider for .NET" invariant="Oracle.DataAccess.Client" description="Oracle Data Provider for .NET" type="Oracle.DataAccess.Client.OracleClientFactory, Oracle.DataAccess, Version=2.112.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342"/>
  <add name="Odbc Data Provider" invariant="System.Data.Odbc" description=".Net Framework Data Provider for Odbc" type="System.Data.Odbc.OdbcFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
  <add name="OleDb Data Provider" invariant="System.Data.OleDb" description=".Net Framework Data Provider for OleDb" type="System.Data.OleDb.OleDbFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
  <add name="OracleClient Data Provider" invariant="System.Data.OracleClient" description=".Net Framework Data Provider for Oracle" type="System.Data.OracleClient.OracleClientFactory, System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
  <add name="SqlClient Data Provider" invariant="System.Data.SqlClient" description=".Net Framework Data Provider for SqlServer" type="System.Data.SqlClient.SqlClientFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/></DbProviderFactories>
</system.data>



<system.data>
    <DbProviderFactories>
        <add name="Odbc Data Provider" invariant="System.Data.Odbc" description=".Net Framework Data Provider for Odbc" type="System.Data.Odbc.OdbcFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
        <add name="OleDb Data Provider" invariant="System.Data.OleDb" description=".Net Framework Data Provider for OleDb" type="System.Data.OleDb.OleDbFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
        <add name="OracleClient Data Provider" invariant="System.Data.OracleClient" description=".Net Framework Data Provider for Oracle" type="System.Data.OracleClient.OracleClientFactory, System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
        <add name="SqlClient Data Provider" invariant="System.Data.SqlClient" description=".Net Framework Data Provider for SqlServer" type="System.Data.SqlClient.SqlClientFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
        <add name="SQL Server Compact Edition Data Provider" invariant="System.Data.SqlServerCe" description=".NET Framework Data Provider for Microsoft SQL Server Compact Edition" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
        <add name="Microsoft SQL Server Compact Data Provider" invariant="System.Data.SqlServerCe.3.5" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=3.5.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
        <add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/></DbProviderFactories>
</system.data>

My connection string looks like this:

<connectionStrings>
<add name="NottherealnameTest" providerName=".NET Framework Data Provider for SQL         Server" connectionString="Data Source=*****************;Initial      Catalog=************;Persist Security Info=True;User   ID=*************;Password=*****************" />
  </connectionStrings>
 </configuration>

I have of course censored some information for security purposes but that is the basic layout.

Can anyone see an error I cant? or has any idea why this may be happening? Any help would be greatly appreciated.

Bohdi
  • 1,295
  • 4
  • 28
  • 62
  • _I have altered the two machine.config_..did you reboot your machine after that? – Pablo Claus Aug 24 '12 at 13:36
  • Yeah, and just rebooted again... :/ – Bohdi Aug 24 '12 at 14:19
  • The first `machine.config` belongs to Framework v.2.x.x and the second to v 4.x, don't they? – Pablo Claus Aug 24 '12 at 14:31
  • yeah, and also I edited the framework64 ones as well just to be sure. has no effect. – Bohdi Aug 24 '12 at 14:49
  • Try to change this line `providerName=".NET Framework Data Provider for SQL Server"` for `providerName="System.Data.SqlClient"`. – Pablo Claus Aug 24 '12 at 15:05
  • When I do that it gives me a new error that states: Unable to retrieve metedata for 'Project.Models.Class'. One or more validation errors were detected during model generation. And then saying that -System.Data.Entity.Edm.EdmEntityType: EntityType 'Class' has no key defined. Define the key for this entity type. – Bohdi Aug 24 '12 at 15:17
  • sorry hit enter to soon and had to edit it, error is above – Bohdi Aug 24 '12 at 15:23
  • Check if your clases have `{ get; set; }` in their keys properties. – Pablo Claus Aug 24 '12 at 15:28
  • The Model Class for the controller I am trying to make, which displays that error has a { get; set;} on every database field as well as one for the class with an error. public class DBName : DbContext { public DbSet NewsItem { get; set; } } ---- something similar to that – Bohdi Aug 24 '12 at 15:34
  • The problem with the provider is solved, I think. Could you put the class fields code in the question? – Pablo Claus Aug 24 '12 at 15:46
  • Yes, I will do when I get home, had to move from my workstation. Thank you so much for the help btw.:) – Bohdi Aug 24 '12 at 16:54
  • Are you going to put your code? – Pablo Claus Aug 28 '12 at 12:31

0 Answers0