问题
I have uploaded my project to a server and everything works fine until I try to "log-in" or "register" using EF
Interestingly, on my PC, I have got this to work with SQL Server Express & SQL Server Compact - it just does not work on the server
On the server, I have SQL Server Express installed
Here is the connection string
<add name="DefaultConnection"
connectionString="data source=(localhost);Integrated Security=SSPI;
database=aspnet-MvcDealerConn-20121005200308;
AttachDBFilename=|DataDirectory|aspnet-MvcDealerConn-20121005200308.mdf;
User Instance=true"
providerName="System.Data.SqlClient" />
Any help would be much appreciated
回答1:
The whole User Instance and AttachDbFileName= approach is flawed - at best! And it's deprecated, too - don't use it!
The way I would solve this is:
install SQL Server Express (and you've already done that anyway)
install SQL Server Management Studio Express
create your database in SSMS Express, give it a logical name (e.g.
DealerConn
)connect to it using its logical database name (given when you create it on the server) - and don't mess around with physical database files and user instances. In that case, your connection string would be something like:
Data Source=servername\\SQLEXPRESS;Database=DealerConn;User ID=SomeUser;Pwd=SecretPwd
and everything else is exactly the same as before...
Since it's hosted on a remote server, I also believe you need to most likely provide a separate, explicit User name and password (and you cannot use the Integrated Security=SSPI;
tag)
来源:https://stackoverflow.com/questions/13205634/sql-server-express-connection-string-on-server-not-working