Problems with EF 4.3 when deployed - asp.net

I have EF4.3.1 installed on my local machine.
I created a new web application project and added the framework. I then created a database/model etc. The framework is split over 2 projects 1 DAL, 1 Entities. On my local machine I'm restricted to SQL Express 2008.
Here is the configuration section from web config:
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.3.1.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</configSections>
Here is the connection string I use:
<add name="PayDayLoanEntities" connectionString="metadata=res://*/Models.PayDayLoans.csdl|res://*/Models.PayDayLoans.ssdl|res://*/Models.PayDayLoans.msl;provider=System.Data.SqlClient;provider connection string='data source=.\SQLEXPRESS;attachdbfilename="C:\Documents and Settings\John\My Documents\Visual Studio 2010\Projects\IL\WebSite\App_Data\PayDayLoans.mdf";integrated security=True;connect timeout=30;user instance=True;multipleactiveresultsets=True;App=EntityFramework'" providerName="System.Data.EntityClient" />
All this works!
On my production machine I use SQL 2008 web edition so, changed the connection string as follows:
<add name="PayDayLoanEntities" connectionString="metadata=res://*/Models.PayDayLoans.csdl|res://*/Models.PayDayLoans.ssdl|res://*/Models.PayDayLoans.msl;provider=System.Data.SqlClient;provider connection string='Data Source=localhost;Initial Catalog=PayDayLoans;uid=***;pwd=********";integrated security=True;connect timeout=30;user instance=True;multipleactiveresultsets=True;App=EntityFramework'" providerName="System.Data.EntityClient" />
However, I get the following error message:
Could not load file or assembly 'EntityFramework, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
The config section refers to 4.3.1 but the error 4.1.0. Anyone know what I'm missing here?
Any help appreciated.

There's a good chance that something in your solution is referencing EF 4.1.0 when built for RELEASE. Perhaps you have a build server that is not updated properly?
Run Fuslogvw (as Administrator or it will silently fail) on your production machine. Start logging bind failures before you start your web application. Fuslogvw will tell you what exactly tried to bind EF 4.1.0.

Related

Issue EntityFramework 5.0.0 connection with oracle 11g

I am using EntityFramework 5.0.0 and my db is oracle11g client 12c Oracle Database (ODP.NET, Managed Driver) Version 12.1.My Database is already exists so i am calling existing tables and i connected my db using edmx its connected fine, But i am not using edmx in my actual application so i coded 1 entity and its configuration by hand, now its not connecting i think my connection string is wrong my web.config code is you can see connection string below
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
</configSections>
<connectionStrings>
<add name="dbContext" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=Oracle.ManagedDataAccess.Client;provider connection string="DATA SOURCE=xxx;PASSWORD=aaa;PERSIST SECURITY INFO=True;USER ID=aaaa"" providerName="System.Data.EntityClient" />
</connectionStrings>
Please tell me solution.
Thanks
below is my connection string which fixed connectivity issue.
<add name="dbContext" connectionString="DATA SOURCE=yourdatasource;PASSWORD=xxx;PERSIST SECURITY INFO=True;USER ID=abc;" providerName="Oracle.ManagedDataAccess.Client" />
Make sure you are using EF 5.0.0 and ODAC 64-bit(if your machine is 64 bit) ODAC 12c Release 2 (12.1.0.1.2) Xcopy for Windows x64
Thanks

Connection 'LocalSqlServer' was not found in the applications configuration or the connection string is empty

I am using windows 8.1 on which I have installed VS2012 and VS2013 and I am running my website on IIS but whenever I run my project it gives an error about LocalSqlServer connection string is empty in my machine config. I looked at my machine config under "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config" directory and found that connection string is there. I have nearly spent 2 days but couldn't get my site to run on IIS. Any help is appreciated?
Server Error in '/GCC.Server' Application.
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: The connection name 'LocalSqlServer' was not found in the applications configuration or the connection string is empty.
Source Error:
Line 257: <roleManager>
Line 258: <providers>
Line 259: <add name="AspNetSqlRoleProvider" connectionStringName="LocalSqlServer" applicationName="/" type="System.Web.Security.SqlRoleProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
Line 260: <add name="AspNetWindowsTokenRoleProvider" applicationName="/" type="System.Web.Security.WindowsTokenRoleProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
Line 261: </providers>
Source File: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.config Line: 259
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34009
This is the complete error as image was not readable due to my laptop resolution.
I got it working and got bit late to reply. Answer is very simple in my case issue was under IIS. I went to IIS. Selected defualt website and clicked on modules. Under modules just remove System.Web.Security.RoleManagerModule.

Visual Studio 2013 Deployment "database does not exist or contains no mapped tables." fault

You can see the below information about my deployment
AutoMigration= true
I have created a database in server.
I select the deploy option with right click to my project, and select my DB server and database.
It has successfully uploaded and deployed my application.
Here is my connection string after deployment to the server :
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections>
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=**.***.***.***;Initial Catalog=MyDatB;User ID=sa;Password=*****" providerName="System.Data.SqlClient" />
</connectionStrings>
And here is my migration config
public Configuration()
{
AutomaticMigrationsEnabled = true;
ContextKey = "ModulericaV1.Models.ApplicationDbContext";
}
But i got the following error when i am trying to launch my application :
Migrations is enabled for context 'ApplicationDbContext' but the
database does not exist or contains no mapped tables. Use Migrations
to create the database and its tables, for example by running the
'Update-Database' command from the Package Manager Console.
Please note : If i did not create my database in development server, my codefirst application is not going to create database for me .. It is also problem i think.

Entity Framework works on Local Server but not Remote

Ok so I have a website that uses ASP.net mvc, the problem I am having is with Entity Framework. I added all the references and got it to run on my local machine but when I publish it I get the following error.
System.InvalidOperationException: The Entity Framework provider type 'System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' for the 'System.Data.SqlClient' ADO.NET provider could not be loaded. Make sure the provider assembly is available to the running application. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information.
I have double checked my references and I have EntityFramework.SqlServer and System.Data both added into my project. The connection string I use to connect to the data base and declare the service provide is below.
<connectionStrings>
<add name="[dataConnection]" connectionString="Data Source=[ip of host machine];Database=[name];UID=[user];pwd=*******;MultipleActiveResultSets=True;" providerName="System.Data.SqlClient" />
</connectionStrings>
Name we just have the name of the data base, this is also used in my web.debug.config
<connectionStrings>
<add name="[dataconnection]"
connectionString="Data Source=.;Database=[name];UID=[user];pwd=*******;MultipleActiveResultSets=True;"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
I am pretty new to this entire thing and was just handed someone elses code so I am trying to learn on the flow. This is my first encounter with this so any direction would be appreciated.
I had the same problem in my integration test assembly (i'm using ms visual studio unit testing framework for this) and i've solved it by adding EF assemblies to deployment items in .testsettings file.
I've installed EF 6 alpha using Package Manager Console using:
Install-Package EntityFramework -Pre
Here is my app.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<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.SqlConnectionFactory, EntityFramework" />
</entityFramework>
</configuration>
My connection string (i'm setting it in code): server=.\SIN;initial catalog=IntegrationTests;User ID=user;Password=pass;MultipleActiveResultSets=true;
I've looked at the EF assembly reference properties to see if they are set to "Copy Local" = True.
And finally i've checked out TestResults/../Out folder and found that there is no EntityFramework.SqlServer assembly there (SqlProviderServices class resides in it).
So i've just added both EF 6 assemblies to my deployment items and now everything is ok
You can try to copy EntityFramework.SqlServer assembly to your web server directory to see if it works.
Maybe this link can be helpful
P.S:
Make sure you don't have a reference to System.Data.Entity, because you'll be using one from GAC. EF 6 Alpha assemblies is not installed in GAC when you install them with Nuget. Target framework should be .NET 4.5.
Sorry for my bad english.
A question: which EF version?
Check your IIS pool .NET version... It should be the one that points to the .NET version of your published project... The assembly of EF should be in the .NET framework folder under Windows directory (AKA GAC)

Unobtrusive Oracle Deployment on Windows Server 2008

I have a .NET 4.0 Web Forms app that I am running with the beta Oracle EF-aware data provider, and I want to perform "unobtrusive" Oracle deployment to a Win2K8 box, as shown in many SO solutions.
There is an existing Oracle Instant Client installation on the Win2K8 box, which I can neither work with nor remove, and it has an entry in the PATH environment variable on the Win2K8 box. According to this SO answer, I do not need to set PATH for my Oracle DLLs, since I have DllPath set in the web.config.
I am following the procedure from here, yet I still get the provider is not compatible with the version of Oracle client error.
Here's my (unsuccessful) setup, as of now:
Oracle DLLs are in my web app's bin directory, and set to Copy Always Do Not Copy.
Platform and Platform Target settings are set to x86 in my local Build Configuration.
32-bit applications are enabled in the app pool (.NET 4.0) on the Win2K8 box.
Oracle DLLs are not present in the GAC, not are they present in the GAC_32 and GAC_64 directories on the Win2K8 box.
My web.config (but not my Win2K8 machine.config) contains this:
<configuration>
<configSections>
<section name="oracle.dataaccess.client" type="System.Data.Common.DbProviderConfigurationHandler, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</configSections>
<oracle.dataaccess.client>
<settings>
<add name="DllPath" value="C:\inetpub\wwwroot\myapp\bin"></add>
<add name="FetchSize" value="65536"></add>
<add name="StatementCacheSize" value="10"></add>
<add name="TraceFileName" value="c:\temp\odpnet2.log"></add>
<add name="TraceLevel" value="0"></add>
<add name="TraceOption" value="0"></add>
</settings>
</oracle.dataaccess.client>
<system.data>
<!-- Version=4.112.2.50 -->
<DbProviderFactories>
<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=4.112.2.50, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</DbProviderFactories>
</system.data>
<connectionStrings>
<add name="MyEntities" connectionString="metadata=res://*/MyModel.csdl|res://*/MyModel.ssdl|res://*/MyModel.msl;provider=Oracle.DataAccess.Client;provider connection string="DATA SOURCE=**<using EZCONNECT format here>**" providerName="System.Data.EntityClient" />
</connectionStrings>
<configuration>
The app itself deploys successfully, and I can run pages that do not reference my Oracle DLLs. But, for those that do reference Oracle, I still get the provider compatibility error.
What am I missing?
Thanks again for the help.
UPDATE: The web app runs on the Win2K8 target with .NET 4.0, EF4.1, and the Oracle EF Provider, completely separate from the other active ODAC install. No PATH variable, no installation from Universal Installer, no Oracle DLLs in GAC.
Case closed. I was missing an Oracle DLL.

Resources