Uzair Ishaq
Uzair Ishaq

Reputation: 3

Problem accessing database for Entity Framework

I've created a windows forms application that would use a client server model for accessing database. I created a connection for Entity Framework Model and it works fine with the following connection string:

connectionString="metadata=res://*/CartonOrderModel.csdl|
                           res://*/CartonOrderModel.ssdl|
                           res://*/CartonOrderModel.msl;
                  provider=System.Data.SqlClient;
                  provider connection string="
                  Data Source=.\SQLEXPRESS;
                  AttachDbFilename=E:\Databases\RollMeasurements.mdf;
                  Integrated Security=True;
                  Connect Timeout=30;
                  User Instance=True;
                  MultipleActiveResultSets=True""
providerName="System.Data.EntityClient"

I wonder if this connection string would still work when i deploy it on client environment which has a central db server and more than one instance of my app would be accessing it from client machines.

I tried changing the connection string to this:

connectionString="metadata=res://*/CartonOrderModel.csdl|
                           res://*/CartonOrderModel.ssdl|
                           res://*/CartonOrderModel.msl;
                  provider=System.Data.SqlClient;
                  provider connection string="
                  Data Source=.\SQLEXPRESS;
                  Initial Catalog=RollMeasurements;
                  User ID=sa;
                  Password=sapassword;
                  Connect Timeout=30;
                  User Instance=True;
                  MultipleActiveResultSets=True""
providerName="System.Data.EntityClient"

But now when I run my app it gives me this exception:

Failed to generate a user instance of SQL Server. Only an integrated connection can generate a user instance. The connection will be closed.

Please help me with this. Thanks!

Upvotes: 0

Views: 422

Answers (2)

Slauma
Slauma

Reputation: 177133

I think you have to remove User Instance=True (or set it to False explicitely). User Instances are local copies of a SQL Express database and not suited for work in a multiuser environment with a central DB.

Upvotes: 2

BonScott
BonScott

Reputation: 1

I think if you want to access to a central server, you need to change the Data Source=.\SQLEXPRESS; line to a central sql server instance.

english is not my mother language so maybe dont understand correctly the question.

Cheers

Upvotes: 0

Related Questions