EntityFramework deployment with AppHarbor - entity-framework

I am running into a strange problem after deploying my site to AppHarbor.
I always get this error :
Exception Details: System.Data.MetadataException: Schema specified is not valid
It is clearly linked with my connection string (which works perfectly on my dev machine)
<add name="DbEntities" connectionString="metadata=res://*/Models.DbModel.csdl|res://*/Models.DbModel.ssdl|res://*/Models.DbModel.msl;provider=System.Data.SqlClient;provider connection string="Server=xxx.sqlserver.sequelizer.com;Database=xxx;User ID=xxx;Password=xxx;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
I dont use EF code first so I cannot remove the metadata section.
Any idea what to do to fix it ? I couldnt find anything to help me get over this...
For Info I am using VS 2012, .Net 4.0, EF 4.4

The AppHarbor knowledge base has info on using the SQL Server add-on, including setting the metadata-string: http://support.appharbor.com/kb/add-ons/using-sequelizer

Related

EntityFramework: unable to determine the provider name for provider factory of type 'system.data.sqlclient.sqlclientfactory'

I have an Website that use Entity Framework and SQLServer.
WHen I trying to run my application on Azure I get the following error:
Unable to determine the provider name for provider factory of type 'system.data.sqlclient.sqlclientfactory'. make sure that the ado.net provider is installed or registered in the application config.
On premises everything works fine.
I have finally discovered that the error was caused by this configuration section (that now I don't use anymore):
<system.data>
<DbProviderFactories>
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, mysql.data" />
</DbProviderFactories>
</system.data>
I have removed it and now it worked correctly.
For future readers, this same error can also be seen when using Visual Studio 2017 v.15.7. I spent days browsing the web for solutions, and stubled upon this GitHub post mentioning a bug in EF Tooling. An update to v.15.8 as mentioned in the post solved the problem for me.

Web.config session-state code error

Firstly, I executed the installsqlstate.sql on to my server and then I wrote sessionstate code.
<sessionState mode="SQLServer" sqlConnectionString="data source=idealserver;user id=sa;password=**" cookieless="false" timeout="20" allowCustomSqlDatabase="true"/>
Then I run my web project, it did not work and it returned an error like
Unable to use SQL Server because ASP.NET version 2.0 Session State is not installed on the SQL server. Please install ASP.NET Session State SQL Server version 2.0 or above.
I don't understand the warning and I don't know how I will continue.
It seems that you may have installed the wrong version. Try running installsqlstate.sql located at
system drive\Windows\Microsoft.NET\Framework\version\v2.0.50727

How to deploy ASP.NET MVC4 application with SQL Server CE to Azure website

I deployed a ASP.NET MVC4 app with SQL Server CE database, but I'm getting
Sorry, an error occurred while processing your request
I am using VS2012 to publish this app to azure website. How can I solve this issue? Thanks.
To summarize and so an answer can get marked on this to help the next person that comes by.
When running into issues on azure-web-sites FTP is a handy debugging tool which enables you to:
Verify that the dll exists in your bin directory
Sometimes the .gitignore file blocks directories from being checked in
Verify that your web.config file has the proper version of the assembly configured
NuGet can help, but it's ultimately up to you to verify your dependencies
Here is a good article to follow on the subject: http://www.dotnetcurry.com/showarticle.aspx?ID=883
Unfortunately with VS 2013 Compact edition is not supported any more, so things are somewhat tricky.

Azure error when using EF agains SQL Server CE 4.0 database

I have an ASP.NET MVC 3 application which I want to deploy to Azure. The application uses EF against a SQL Server CE 4.0 database in the App_Data directory.
The site runs fine locally but when I reference it from an ASP.NET MVC 3 web role and publish it to Azure I get this error:
"Unable to find the requested .Net Framework Data Provider. It may not be installed."
The full exception can be viewed here: http://52df5a4a5c1b4d10a927078bb8a06d15.cloudapp.net/drug
Here is connection string from the web.config file:
<add name="DbEntities" connectionString="metadata=res://*/AMDBModeledmx.csdl|res://*/AMDBModeledmx.ssdl|res://*/AMDBModeledmx.msl;provider=System.Data.SqlServerCe.4.0;provider connection string="Data Source=|DataDirectory|\AMDB.sdf"" providerName="System.Data.EntityClient" />
I have tried compiling my project to target x86 and setting the "Copy Local" property of the System.Data.Entity reference to true. Nothing helps.
Is it possible to run a web app in Azure and use a file-based database? I understand this can be a problem with multiple instances, but I'm only using a single VM.
I can't see your error page, but it looks like the SQL CE Data Provider DLL is missing. Have you tried following these instructions?
http://blogs.msdn.com/b/webdevtools/archive/2011/01/06/how-to-bin-deploy-sql-compact-edition-4-0-and-razor-web-projects.aspx

Entity Framework 4 CTP 5 POCO - Using an existing but empty SQL database on hosting environment?

I'm using EF 4 CTP 5 with an MVC 3 application, everything is working fine on my local machine, where EF 4 just create or drop the SQL CE whenever it needs to, since I have set the option to DropCreateDatabaseIfModelChanges. But I'm now trying to deploy my mvc application to a hosting environment, where I've created the database already, but the database is empty. It seems like the code can't drop, and recreate the database on my hosting environment, how should I solve this problem?
Update:
Here's the connection string to SQLEXPRESS:
<add name="KennySax"
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;
database=KennySax;
AttachDBFilename=|DataDirectory|KennySax.mdf;
User Instance=true"
providerName="System.Data.SqlClient" />
Thanks.
One other option is to use Joachim Lykke Andersen's DontDropDbJustCreateTablesIfModelChanged database initializer
It deletes and re-creates the tables if the model changes
He even has a NuGet package for it
Usually your running application in hosting environment doesn't have permissinons to modify DB structure. So you can run your application in your own environment and use Management studio to connect to SQL CE. Then generate SQL script from your DB and manually run that script in hosted environment. I hope it works with SQL CE - it will definitely work with SQL Express.
Well I'm not sure what I did, seems like a restart of the machine solved the problem. I was able to have SQLEXPRESS create the database and run the script on the hosting server. Thanks.