I'm currently working on a MVC application which uses Entity Framework to interact with an Oracle Database.
Creating the edmx, adding and updating tables, all those actions are done without raising any error since I've installed all the Oracle providers I needed to make it work with .NET.
However, here's the thing : when I'm trying to run my app (which is done without errors), when the following line is executed, Visual Studio raises an error.
return PartialView("_GridViewRecruitmentPartial", model.Where(e => e.NON_ACTIVE != 1).OrderByDescending(e => e.EMPL_ID).ToList());
The error message :
The specified store provider cannot be found in the configuration, or
is not valid.
And the inner message:
Unable to find the requested .Net Framework Data Provider. It may not
be installed
I'm aware that something's wrong with EF and Oracle but can't see what. Plus, I've plenty of other projects using those 2 and everything went well.
Any guess?
I am not sure what are you using for data access. There are multiple Oracle providers... Anyway, you should probably use official Oracle Managed driver from Nuget.
When you install it from Nuget it should add itself to your web.config so everything works..
<entityFramework>
<providers>
<provider invariantName="Oracle.ManagedDataAccess.Client"
type="Oracle.ManagedDataAccess.EntityFramework.EFOracleProviderServices, Oracle.ManagedDataAccess.EntityFramework, Version=6.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342"/>
</providers>
</entityFramework>
Related
I have created a Class Project (Class Library) for Login. I have installed EF >> created models >> Created Data Context file >> Executed "enable-migration" command in NuGet Package Manager >> Executed "add-migration" command in NuGet Package Manager.
Now when I was trying to executed last step - "update-database" command in NuGet Package Manager, it threw an error "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)". There is no issue with connection because I repeated the same steps, but this time I used Web Project. It worked successfully.
Reason why was I doing this: I have 3 different application which uses same user authentication. I thought I can refer this class project in all 3 projects for authentication.
Am I doing something wrong? What am I missing? Or is it that Class project doesn't support EF? Is there any work around?
Edit: Class Library uses App.Config and Web Application uses Web.config.
Thank you in advance.
PS: Warning Advice for auditors - I just need answers. Please don't try to tell me that this question is duplicate, not following rules, etc. because I don't care. Let me get answer then you may block my question all you want. Till then have patients and sit quietly without making any comments.
Finally, I found solution to this.
When I install Entity Framework, EF places some default code in application's config file. As below:
Problem Code:
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
Solution:
This was root of the problem I was facing. By default it was creating a local connection string for itself. I made following changes:
1.) Changed "LocalDbConnectionFactory" to "SqlConnectionFactory"
2.) Removed parameters tag completely.
So it should look like this:
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
I'm attempting to use Entity Framework 6 within an addin for a program I don't have control over.
I've built a class library to contain my context / model logic and I want to be able to consume that within my addin assembly. I am able to consume it as desired within an application no problems, but consuming application requires an app.config file containing the available connection factories (in my case Sql and Sql Ce).
The addin must be compiled as a class library and as such the app.config file within that project is not used - instead I suspect it uses the app.config file of the program under which the addin runs. As a result I'm getting the exception
'No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlServerCe.4.0'. Make sure the provider is registered in the 'entityFramework' section of the application config file. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information'
I've tried many weird and wonderful things with no success, I believe the closest I've come is the following:
Contained within the addin:
public static ProjectContext GetContext() {
SqlCeConnectionStringBuilder sqlBuilder = new SqlCeConnectionStringBuilder {
DataSource = #"C:\Test.sdf"
};
DbConnection connection = new SqlCeConnection(sqlBuilder.ToString());
return new ProjectContext(connection);
}
Contained within my API class libray:
public ProjectContext(DbConnection connection) : base(connection, true) {
Database.SetInitializer(new MigrateDatabaseToLatestVersion<ProjectContext, Configuration>());
Database.CreateIfNotExists();
}
The exception occurs here, when trying to access data from the context (in the addin):
var ctx = GetContext();
List<Model> list = Project.Models.Where(model => model.ParentId == 0).ToList();
All of the above is 100% working when run in a separate application as a .exe with the EntityFramework NuGet packages for Sql and Sql Ce and an app.config file containing the following:
<entityFramework>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
<provider invariantName="System.Data.SqlServerCe.4.0" type="System.Data.Entity.SqlServerCompact.SqlCeProviderServices, EntityFramework.SqlServerCompact" />
</providers>
</entityFramework>
Is there anything I can do to make my program run as an addin in this case? I was hoping that passing the actual database connection to my ProjectContext would remove the dependency on the app.config providers list. Is there something that I've missed that can achieve this?
Most of what I've been able to find around this topic seems to be about passing in the connection string so I'm at a loss!
Thanks in advance!
I know that this problem has been encountered by many users here on SO but I cannot seem to find a permanent solution.
I keep encountering the error "could not load file or assembly 'mysql.data,' version=6.7.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d".
I am using Visual Studio 2012 Version 11.0.61030.00 Update 4. I have installed MySQL version 5.6.15.0 for Visual Studio. After installation, I notice that the machine.config file for both the 32 and 64 bit entries show Version=6.6.5.0 even though I have never installed a MySQL of that version.
I then check the project references for MySql.Data and MySql.Data.Entity and they are the correct version, i.e. 6.7.4.0 and copy local property set to true.
I even copy this to my App.config file:
<system.data>
<DbProviderFactories>
<clear />
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.7.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</DbProviderFactories>
</system.data>
My application .NET 4.5 will run fine until I shut down my computer. If I work on my machine for 4 days without switching it off no problem.
After I shut down and restart my machine, the error comes up. I then try to manually change the machine.config settings to the version 6.7.4.0 but to no avail. I try to change the project configuration settings from any CPU to x86 but no solution.
When I encounter this, the only way I get to fix this is to uninstall MySQl and reinstall it again.
Is there a permanent solution to this problem? I have tried this MySQL connector 6.7.4 and Entity Framework 5 exceptions but like I say it seems a temporary solution.
I could be off on this but you could change the references specific version value to false.
Right click on the reference > Select Properties > Change the Specific version value
An error occurred while getting provider information from the database. This can be caused by Entity Framework using an incorrect connection string. Check the inner exceptions for details and ensure that the connection string is correct.
Inner Exception: {"The provider did not return a ProviderManifestToken string."}
I've searched other threads as there are many with similar errors, but I cannot seem to find a solution.
I am using VS2012 Professional and SQL Server 2012. I am able to connect to the server using Server explorer using windows authentication. I am building a webforms application with multiple tiers. One of them containing my Entity framework tier which contains my Context class.
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
<connectionStrings>
<add name="MYSQLSERVER"
providerName="System.Data.SqlClient"
connectionString="Data Source=myComputer\MYSQLSERVER;Trusted_Connection=true"></add>
</connectionStrings>
</configuration>
This is what the app.config in my Entity Framework class library layer looks like.
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
</configuration>
Also, I have tried changing the app.config defaultConnectionFactory type to
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework">
but it did not change anything.
I am not really sure what any of the changes I am making even mean which worries me. Sure I could of found the solution online and fixed my issue, but I would really like to understand the web.config and what this all means. On top of finding a solution to this problem, can anyone point me in the right direction to learning web.configs?
Thank ahead for your help.
In my case, it was my SQL Server instance that was not running. I simply started the service and everything worked fine. Hope this helps someone down the road.
I also faced to this error and I solve that downgrading these NuGet packages
MySql.Data - 6.9.12
MySQL.Data.Entity - 6.8.8
this is my reference URL which I referred
Well I fixed it.
Just needed to put "." for localmachine in the data source as follows:
<add name="MYSQLSERVER"
providerName="System.Data.SqlClient"
connectionString="Data Source=.\MYSQLSERVER;Trusted_Connection=true"></add>
</connectionStrings>
Here's another possible cause:
I have both my (ASP.NET) HTTP server and MySQL/Aurora server on AWS (understood that AWS was not part of the OP's comments).
My desktop's (actually, our building's) IP was whitelisted in the MySQL/Aurora server's security group, so everything worked perfectly for development.
But the ASP.NET server's IP was not whitelisted for the MySQL/Aurora instance, thus the ASP server's EF connection request was being rejected, and that was causing the exception noted at the top of this thread.
Esoteric, but maybe this helps someone.
For those getting this recently, in updating to MySql.Data 8.0.19 you also have to update your references for EntityFramework, Oracle changed the package, it's now MySql.Data.EntityFramework instead of MySql.Data.Entity or MySql.Data.Entities. Props to David Sekar: https://davidsekar.com/asp-net/mysql-error-the-provider-did-not-return-a-providermanifesttoken
For me, It was all of the below.
1. DB not allowed to connect to my dev environment. May be firewall restrictions.
2. Connection string had wrong credentials for the DB.
So generally speaking, incorrect connection string.
i meet this problem when i try to connect to mysql, the reason is that i forget to add the "password" in "connectionStrings"
In my case the paramter was v12.0, I changed to v11.0 and it is working
I had the same problem, reinstalling Npgsql with the package manager did the trick.
Seemed to be a versionning problem.
For me, it was using double backslash between the server and the instance, such like .\SQLExPRESS;...etc.
The correction was to use .\SQLEXPRESS
hope it helps someone.
I often forget why this error comes often. For me its usually I have changed credential of the database and did not change the same on the code section.
Just in case if I come here again to remind myself.
..and FINALLY(?!?) don't forget to build your project with 'Prefer 32-bit' checked as this will eliminate the KNOWN BUG which generates this error message (which has the inner exception message = 'Arithemtic overflow')
Background-info:
I'm using Microsoft Visual Web Developer 2010 Express.
Info about my (lack of) experience: the problem occured within the first tutorial that I'm trying to work through.
Some additional-info:
I'm comfortable with C#, Postgres, Rails (so MVC & Web-apps are not new to me)
I have no experience with ASP.NET or SQL Server
Problem Description:
I'm trying to following exactly the steps from the "Intro to ASP.NET MVC 3"-tutorial and I'm running into a problem at the first step from part 5 - Adding the MoviesController:
When I'm trying to add the "MoviesController" with the exact settings that are shown in the tutorial and click 'Add' I get the following error:
"Unable to retrieve metadata for
MvcMovie.Models.Movie. Unable to
find the requested .Net Framework Data
Provider. It may not be installed."
Google gave a ton of results when searching for the phrase "Unable to find the requested .Net Framework Data Provider", but nothing has solved the problem so far.
What I've tried:
I think SQL-Server was not installed so I installed it from the Visual-Studio Express ISO- got an error then I've run a repair from the ISO and it claimed that all 15 points including SQL Server Express repair &.NET 4 Framework went through successfully.
I've run the The_.NET_Framework_Setup_Verification_Tool which succeeded for everything.
http://blogs.msdn.com/b/astebner/archive/2008/10/13/8999004.aspx
After the mentioned (re-)installing & repairing I recreated the Project and followed every step as described in the tutorial and got the same error.
I found that I should look for DbProviderFactories in machine.config,
The root-Web.config of the Project has the following entries
<connectionStrings>
<add name="MovieDBContext"
connectionString="Data Source=|DataDirectory|Movies.sdf"
providerName="System.Data.SqlServerCe.4.0"/>
My machine config-file has only one DbProviderFactories entry:
<DbProviderFactories>
<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"/></DbProviderFactories>
then I found the following quote
"we have changed the way
DbProviderFactories.GetFactoryClasses()
determines the framework providers in
VS2010. They are no longer listed in
the machine.config file. "
from http://social.msdn.microsoft.com/Forums/en-ZA/adodotnetdataproviders/thread/d79129c4-ae05-4c45-8997-bd90f5765a3a
Question:
So perhaps this is the wrong direction and since I have no clue what to try next, what steps should I take to investigate & solve this problem?
Btw. I have postgres installed, so if using postgres instead of SQL-server would be an easy solution let me know. For my own projects I would want to use a different DB anyway (probably postgres), but for now I would just want to be able to get successfully through the first and seemingly simple tutorial I've tried.
I was having the same problem so I replaced
<add name="MovieDBContext" connectionString="Data Source=|DataDirectory|Movies.sdf"
providerName="System.Data.SqlServerCe.4.0"/>
with the following
<add name="MovieDBContext"
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;database=Movies;User ID=sa;password="
providerName="System.Data.SqlClient"/>
And it worked enough to let me continue working. I too would also eventually learn how to make these kinds of applications work with mysql at some point, but for now this should at least help you continue with the tutorial.
You need to install Microsoft SQL Server Compact 4.0.
If you look at the config you'll see that installing SQL Server was a red herring;
<add name="MovieDBContext"
connectionString="Data Source=|DataDirectory|Movies.sdf"
providerName="System.Data.SqlServerCe.4.0"/>
SqlServerCE is not, I'm afraid, full blown SQL Server, it's SQL Server Compact Edition. I would have thought that would have been installed with VS Express, however you can download the specific installers from here
I actually had both SQLServerCE and Express installed, but the tutorial used Compact Edition:
One step within part 4 of the tutorial is to explicitly add the part you quoted to the Web.config. So this is a part of the web.config by intention.
But deleting this part from the web.config makes it possible to add the Controller in the way the tutorial described it. While this means no longer exactly following the tutorial, it's fine for me. (This results in the creation of an MvcMovie.Models.MovieDBContext database in SQL Server Express.)
http://forums.asp.net/t/1679349.aspx/1
CypressBender
Re: Unable to retrieve metadata for * Unable to find the requested .Net Framework Data Provider....
Aug 08, 2011 07:44 PM|LINK
I installed Microsoft SQL Server Compact 4.0, and that fixed the problem for me.
http://www.microsoft.com/download/en/details.aspx?id=17876
I changed my SQL providerName="System.Data.SqlClient" in web.config , since I have SQL client as well as SQL compact installed on my system.
Rebuilding the project wont catch config errors in the DBContext section... the build process does not walk through connections, so you can build all day and still bomb out. As suggested above, fix the config so the connection string matches MachineName/SQLInstanceName/DBName with the correct SQL config. Worked just fine by just modifying my web.config in my solution.
Make sure that you build prior to adding the controller. If that doesn't work...
Create a new project, create a new sql server database manually and see if you can connect to it. If not, then the problem is indeed in your sql server config on your machine. You can try going to postgres just be sure that the provider you choose has support for EF code first.
What I did was in order to overcome the first problem I put in Web.config the code:
<add name="MovieDBContext"
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Movies.sdf;Integrated Security=True"
providerName="System.Data.SqlClient"/>
Notice I am creating SQL CE 4 database, therefore the .sdf and not .mdf
Next, you should receive another connection errors on the page /Movies, so replace the above code with :
<add name="MovieDBContext"
connectionString="Data Source=|DataDirectory|\Movies.sdf;"
providerName="System.Data.SqlServerCe.4.0" />
And you should be fine.
I had a server. It ran windows updates. And a message waiting for restart was open.
After restart it worked again.
Install Microsoft SQL Server Compact 4.0. The link for same is - http://www.microsoft.com/en-us/download/details.aspx?id=17876
This worked for me, hope it helps
<add name="MovieDBContext"
connectionString="Data Source=(local);Initial Catalog=Movies; Integrated Security=true;" providerName="System.Data.SqlClient" />
</connectionStrings>
After reading other discussions around the web I have found another method.
If you do not add the connection string until after you have created the controller class, then it will work also. It kind of seems like a bug.
Try this:
<add name="MovieDBContext"
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|Movies.sdf;User Instance=true"
providerName="System.Data.SqlClient" />