I have developed a website application under visual studio using the MVC Pattern and Entity Framework 6.
This web app was linked to a local database.
I've published the application on my azure acc. I also exported the database on Azure following this tutorial.
However, I can't find a way to link the online app to the migrated database.
No data is displayed on the app and when I try to check for the connexion string I get an error , the connexion string hasn't been updated and therefore the app is still trying to target my local database.
I would like to know if anyone might know how to solve this.
EDIT : The problem may be somewhere else, I apparently have two connexions , one for my migrated DB and one for my local db. Perhaps I need to remove the connexion string targetting my local DB but I don't know how to do that
Also, since the Migrated database is a copy from the local one I was using before, do I need to change anything in my Model,views or controller ?
EDIT2 : Thanks to the comment below I was able to override the false Connexion String. However my datas are still not displayed on my application and I haven't found yet what could have happend.
I suspect that my model is still the same model as the one used by the local database as it has the same name. Does anybody know how to change the model to the current model of the online database ?
Thanks.
Because you created your app with entity framework there should be a connection string defined in the web.config file pointing to the local database.
<connectionStrings>
<add name="MyContext" connectionString="..."
providerName="System.Data.SqlClient" />
</connectionStrings>
If you have published your Website as WebApp (App Service) then you can change the connection string for the database under the Application Settings pane on the WebApp Page.
You can override your connection string by creating a connection string settings entry with the name of the connection string in the web.config file.
(For the snippet above - MyContext)
Related
I have two projects in my solution:
An ASP.NET Web API project with EF
A console app with EF
Both projects are configured to connect to SQL Server and have the same connection string defined in the app/web.config:
<add name="AppContext"
providerName="System.Data.SqlClient"
connectionString="Data Source=localhost\SQLEXPRESS;Database=XYZAC;Integrated Security=True" />
The problem only occurs with the console app. The web app creates the XYZAC database correctly. The console app, however, creates a database with the name along the lines of Namespace.AppContext, which isn't at all what I need. Because of that there is no communication between these projects.
I tried changing Database= to Initial Catalog= in the connection string of the console app, but it didn't change anything.
What can be the cause of this? Can this be happening because the API is logging in via IIS APPPOOL\XYZAC user and the app via WINSRV\Administrator? Seems unlikely, because both have pretty much the same permission groups and access to everything, but I'm not sure what else can be the cause.
What am I doing wrong here?
Edit: I'm sharing the DB models between these two projects. I'll try hard-coding the connection string into the constructor.
Try scaffolding from created xyz database to the console application and see if it connects with the scaffolded context .
Hard-coding the same string like this solved the problem:
public AppContext() : base("Sql n stuff;XYZAC")
Cool. As long as it works, right?
I cannot figure out why I'm receiving the above error in my ASP.NET MVC site.
Some background, this site has existed and has been working in my DEV environment for several months. I'm using SQL Server and the ADO.NET Entity Data Model to `Update the Model from the Database'. Recently, I did some pretty large updates that involved changing a few tables around. Then I began receiving this error.
What I've tried:
Clearing browser cache, and using different browsers
deleting all generated tables in the .EDMX file and re-updating them
deleteing the .EDMX file entirely and recreating it
confirming my connection strings (the web.config hasn't been updated at all)
the server is working fine. I can use it in all other apps and SSMS
begging to no one in particular
below is the connection string created:
<add name="RetailDB" connectionString="metadata=res://*/Helpers.RetailDB.csdl|res://*/Helpers.RetailDB.ssdl|res://*/Helpers.RetailDB.msl;provider=System.Data.SqlClient;provider connection string="data source=****;initial catalog=RetailDatabase;persist security info=True;user id=******;password=******;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
I'm sure this is probably something I'm overlooking, but I don't understand why it has decided to start trying to create the database itself. Please let me know what other information I can provide.
I have MySQL Database that Contain data i want to view in KenticoCMS 7.0
since there is no support from Kentico to MySQL DataBase , i have change the Connection string inside Web.config file
from : SQL Server Connection String
to : MySQL Connection String
and the result was kicking out to configuration Page
<add name="CMSConnectionString" connectionString="Persist Security Info=False;database=SaDb;server=.\SQLExpress;user id=sa;password=P#ssw0rd;Current Language=English;Connection Timeout=240;" />
to reconfigure Database Again like first time i install Kentico
<add name="MySQLConnection" providerName="MySql.Data.MySqlClient" connectionString="Server=localhost;Database=test;Uid=root;Pwd=root;" />
is there is any idea about view(just view) mySql data without convert it to SQL Server DB
or making Web service to do this process?
You can't change the main connection string of Kentico database. It results in new database installation as you described. In your situation you will have to develop a custom code to connect to MySql database. Creating a custom webpart may be a good way. Basically what you need to do:
Create a custom webpart - how to do it.
Install MySql drivers - copying assemblies from MySql connector-net into your website bin should be enough. Package can be downloaded here.
Connect to MySql database - tutorial here.
Retrieve and display data in a way you want.
I am successfully running tests through the the WCF Test Client, until I try to pull in data with Entity Framework.
To make sure I'm not doing anything stupid, I downloaded the sample code from this tutorial, which is doing something similar: http://www.codeproject.com/KB/WCF/WCFandEF.aspx
...and when I run it, I get the same error in a similar place:
var productEntity = (from p in context.ProductEntities
where p.ProductID == id
select p).FirstOrDefault();
The error is
The underlying provider failed on Open.
I can open the database fine from a "normal application" with the same connection string, it seems to be specific accessing the DB from the WCF test client.
Research here and on Google for "The underlying provider failed on Open." usual indicates that it's a connection string problem, but I'm pretty sure it's not in this case.
So now I expect it's some sort of permissions problem.
I am using SQL Server and Windows 7, with visual studio 2010.
I have been banging my head since yesterday, so any help or protective head gear appreciated.
Edited to include connection string
<add name="NorthwindEntities"
connectionString="metadata=res://*/Northwind.csdl|res://*/Northwind.ssdl|res://*/Northwind.msl;provider=System.Data.SqlClient;provider
connection string="Data Source=localhost;Initial Catalog=Northwind;User ID=sa;MultipleActiveResultSets=True""
providerName="System.Data.EntityClient" />
This error means 100% a problem in your connection string.
A good way to create a surely working connection string is to create a new(dummy) project, add an Entity Framework Data Model to it, select "Generate Model from Database", select your required connection, and click "Test Conntection" to be sure it works.
Make sure ""Save entity conection settings in App.Config as:..." is ticked.
Than, in you web/app.Config, you have a Connection String you can copy+paste to your own project
Have you tried inserting the database password into the connection string?
It worked for me.
Reference:
http://stack247.wordpress.com/2011/03/02/entity-framework-exception-the-underlying-provider-failed-on-open/
Well I had the same error for days... actualy for two days and Yes I found the solution Alhamdulillah..
As for me... I had Windows Authentication set on my Entity Service Connection.. So What I did was I went to IIS 7 Application Pool Advanced Settings for the web service... Changed the Identity from 'ApplicationPoolIdentity' to 'Network Service' and I setup my current user name and password as well.
I might face some other issues later on, still I would say a Good Start :-)!
I was remove "integrated security=True;" solved this way.
I have a website writen in ASP.NET and C#.
The site works when run locally, however I don't have any experience with uploading. Recently I got a free hosting package from somee.com and am currently trying to upload it.
Basically, the pages that don't require database connection work, the ones that do don't. So, I've created a database on somee.com and attached my database to that. I've tested it through somee.com control panel with a couple of querys and it works fine.
So I believe the site is uploaded correctly, database works also. I figure it must be a connection problem. In my codebehind, every database connection uses the web.config connection string. I believe there is a problem somewhere in the web.config file, specifically with the connection string.
I have replaced my connection string with the connection string generated by the somee.com control panel which is:
<add name="feniks_dbConnectionString"
connectionString="workstation id=SQLEXPRESS003.mssql.somee.com;packet size=4096;user id=*;pwd=*;data source=SQLEXPRESS003.mssql.somee.com;persist security info=False;initial catalog=SQLEXPRESS003"
providerName="System.Data.SqlClient" />
I've marked my id and pass with *. I keep getting the same error, you can try it yourself on http://aspsitetest.somee.com/index.aspx.
Error on page not about sql-connect - it writes about wrong web.config
search for duplicate:
There is a duplicate 'system.web.extensions/scripting/scriptResourceHandler' section defined
If the same web.config works on local machine, maybe you use another version of IIS.