EntityFrame work connection string issue - silverlight

I am working on a Silverlight application. during development I have been working with a copy of our production database on my local machine.
When setting up the project I created a model of the local database, and then created a domain service of that model to interact with the data. This is all working well. Now I need to test my product against the live server, but I can not seem to figure out the connection string.
Currently the connection string looks like this.
<add name="UserDataEntities" connectionString="metadata=res://*/Models.UserDataModel.csdl|res://*/Models.UserDataModel.ssdl|res://*/Models.UserDataModel.msl;provider=System.Data.SqlClient;provider connection string="data source=.;initial catalog=RTRP20112_NATP_UserData;integrated security=True;multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
The only differance between the database I have been using locally, and the production database is its location. I have attempted to simple replace the data source portion of the connection string with the correct address, and login info but that does not work. I have also duplicated the connection string used by another application to connect to this database, but that does not work since it is missing all the metadata junk(i think). I am not sure how to proceed.
The connection string used by other programs to connect to the server is
<add name="UserDatabase" connectionString="Data Source=*.*.*.*,*;Network Library=DBMSSOCN;Initial Catalog=RTRP20112_NATP_UserData;User ID=*;Password=*;" providerName="System.Data.SqlClient"/>
I have tried a few variations of the two as a connection string, most recently I am using.
<add name="UserDataEntities" connectionString="metadata=res://*/Models.UserDataModel.csdl|res://*/Models.UserDataModel.ssdl|res://*/Models.UserDataModel.msl;provider=System.Data.SqlClient;provider connection string="data source=*.*.*.*,*;Network Library=DBMSSOCN;Initial Catalog=RTRP20112_NATP_UserData;User ID=*;Password=*;App=EntityFramework"" providerName="System.Data.EntityClient" />
The most recent error is: Load Error
System.ServiceModel.DomainServices.Client.DomainOperationException:Load operation failed for query 'GetUsers'. The undelying provider failed on Open.

Have you configured/created ASPNETDB ?

Related

How to create the Data Source property of the ConnectionString in ASP/net MVC?

I can't find a decent tutorial/blog that has a solution for my problem.
On my laptop I run a Microsoft SQLServer named 'SQLSERVER'. There's a database in it called 'SalesDB'. I can't figure out how to fill in the Data Source property of the ConnectionString in the web.config file in my ASP.NET MVC 4 application to get my application connected with the database.
This is the default connectionstring:
<connectionStrings>
<add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-Labo7SQL-20131226161445;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-Labo7SQL-20131226161445.mdf" />
connectionstrings.com tends to be a pretty useful resource for formatting a connection string. For MS SQL Server, you have a few options. Such as:
Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;
or
Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;
or
Server=myServerName\myInstanceName;Database=myDataBase;User Id=myUsername;Password=myPassword;
Using the last one as an example, yours might be something like:
Server=localhost\SQLSERVER;Database=SalesDB;User Id=myUsername;Password=myPassword;
The Data Source value should be the name (or ip address) of your sql sever. The Initial Catalog value should be the name of your database...SalesDB and you should remove the AttachDBFilename

Cannot connect to Database with Entity Framework

Every time I have a fresh install of Windows, Visual Studio and Sql Server I always have problems getting an application to connect to the local instance of Sql Server.
I am trying to start an application using Entity Framework code first. Here is my connection string.
<add name="KCSoccerDataContext"
connectionString="Data Source=.\MSSQLSERVER;Initial Catalog=KCSoccer;Integrated Security=SSPI"
providerName="System.Data.SqlClient" />
I am able to connect to the database instance using Sql Server Management Studio, but can't seem to connect using this connection string. I am assuming the problem has to do with how the database instance is configured.
The error I'm getting is
{"The provider did not return a ProviderManifestToken string."}
I'm not exactly sure what this means or where to go from here.
Any help anyone could give on this would be awesome.
Thanks
Use just this connection string:
<add name="KCSoccerDataContext"
connectionString="Data Source=.;Initial Catalog=KCSoccer;Integrated Security=SSPI"
providerName="System.Data.SqlClient" />
MSSQLSERVER is name of default instance. It is not used in connection strings. It even doesn't work from Management studio if you try using it. Only names of custom instances must by used.
You probably didn't enable remote connections for SQL Server since it's a fresh installation. Follow first solution here or here.

how to setup MVC application to use sql server 2008 r2 express

I am trying to follow the tutorial on the building my first MVC application for here
all was good until I needed to run the application an entity framework should have done it's thing and create the data base for me, but for some reason I always get the same error :
The provider did not return a ProviderManifestToken string.
my question:
what are the necessary adjustments i need to do in order for the application to work?
here is my web.config file connection string section
<connectionStrings>
<add name="ApplicationServices"
connectionString="data source=Moran-Laptop;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"
providerName="System.Data.SqlClient" />
<add name="MovieDBContext"
connectionString="Data Source=|DataDirectory|Movies.sdf"
providerName="System.Data.SqlServerCe.4.0"/>
I think your data source is not correct. Does it work with:
<add name="ApplicationServices"
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"
providerName="System.Data.SqlClient" />
If you inspect the exception you will find out that there is InnerException as well which most probably points to SqlException and its inability to find the database or server. Your ConnectionString expects that you have Sql Server CE database available in your App_Data folder. The tutorial that you are looking does not yet tell you that you have to add a new SQL Server CE database to your App_Data folder. Check part 5 of the tutorial http://www.asp.net/mvc/tutorials/getting-started-with-aspnet-mvc3/getting-started-with-mvc3-part5-cs
First off you need to change your connection strings to point to the servers instance of sql server rather than to your laptop
in your connection strings replace Moran-laptop with "server-name\db name" i.e. r2008sqlserver\movies

MVC3 changing default connection string error

I created an MVC3 Internet application and changed the default connection string to work with
.\SQLSERVER instead of the default .\SQLEXPRESS and get following 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: Shared Memory Provider, error: 40 - Could not open a connection to SQL Server)
I tried creating an empty MVC3 application as well, which has no connection string by default and added mine with the same result.
The SQLSERVER instance is running and I can connect to it from management studio using windows authentication. Any connection string that I use gives same error, I cannot figure it out:
<connectionStrings>
<remove name="LocalSqlServer" />
<add name="LocalSqlServer" connectionString="data source=.\SQLSERVER;" providerName="System.Data.SqlClient" />
</connectionStrings>
To connect to your local default instance (i.e. SQLSERVER service name), for Data Source=..., use one of the following:
127.0.0.1
localhost
(local)
.
EDIT
Your connection string should resemble this:
Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;
Checkout the different connection strings you can use with SQL Server. For example if you have a SQL Server installed on your local machine you could use the following connection string:
Data Source=127.0.0.1;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;
Obviously you will need to adjust the name of the database, the username and password to connect to.
If you want to use Windows Authentication to connect to the server:
Data Source=127.0.0.1;Initial Catalog=myDataBase;Integrated Security=SSPI;
Your connection string needs to look something like this:
<add name="NameOfConnection" connectionString="Data Source=localhost;Initial Catalog=OMSCING;Trusted_Connection=Yes" providerName="System.Data.SqlClient" />
Where you can replace localhost with a hostname or leave it like that if the server's local.
Perhaps I had to mention that I was using EF with code first approach, but the problems was due to the name of the connection string which should be the same name as your Context which you derive from DbContext, e.g.:
<connectionStrings>
<remove name="ApplicationServices"/>
<add name="MyContext"
connectionString="data source=localhost; Initial Catalog=CoolCars;Integrated Security=True;" providerName="System.Data.SqlClient" />
</connectionStrings>
as well make sure you remove the default machine.config connection string which is for .\SQLEXPRESS

Converting Entity Framework connection string to SQL Server Express

My project has an Entity Framework connection string but I want to connect to a SQL Server Express database, so I think I have to change the connection string to SQL Server Express - but how ?
I want to change below connection string. Is it also enough connect database just changing connection string for same SQL Server mdf file ?
<add name="MyEntities"
connectionString="metadata=res://*/Model.MyEntities.csdl|res://*/Model.MyEntities.ssdl|res://*/Model.TravldbEntities.msl;
provider=System.Data.SqlClient;
provider connection string="Data Source=sandiego;
Initial Catalog=mydatabse;Persist Security Info=True;
User ID=user;Password='password';MultipleActiveResultSets=True""
providerName="System.Data.EntityClient" />
What have you tried? I'm not familiar with EF, but why not just try something similar to how a normal C# app would connect:
<add name="MyEntities"
connectionString="provider=System.Data.SqlClient;
Data Source=sandiego; -- maybe needs to be sandiego\SQLEXPRESS?
User ID=user;
Password=password;">
I would only specify the MARS attribute if you know for sure you need it.
Instead of this:
Data Source=sandiego
Use this:
Data Source=SomeMachineNameOrIP\SQLExpress
Here's another similar answer.

Resources