c# - How to allow IIS to use local database from ASP.NET MVC project? -
i'm going demoing asp.net mvc website on local network. application has connection database:
<connectionstrings> <add name="defaultconnection" connectionstring="data source=(localdb)\v11.0;attachdbfilename=|datadirectory|\aspnet-ebc-20141127093222.mdf;initial catalog=aspnet-ebc-20141127093222;integrated security=true" providername="system.data.sqlclient" /> </connectionstrings>
i if database can used both iis , whenever run application locally. i've made site on iis - running .net v4. project lives in c:\inetpub\www\ebc
. can publish website recieve error upon viewing page:
"a network-related or instance-specific error occurred while establishing connection sql server. server not found or not accessible. verify instance name correct , sql server configured allow remote connections. (provider: sql network interfaces, error: 50 - local database runtime error occurred. unexpected error occurred inside localdb instance api method call. see windows application event log error details."
i know need allow remote connections sql server through microsoft sql server manager? there way elsewhere?
the best solution use sql expression if don't want there few steps have make mvc application work localdb
- open visual studio command prompt administrator
- execute
sqllocaldb share v11.0 iis_db
(then database shared , iis can access it) - change site connection string point shared instance of db:
data source=(localdb)\.\iis_db
publish again
note in point may receive access deny error , there how fix
- go visual studio => databaseexplorer => add connection
for server name enter
(localdb)\.\iis_db
right click on connection , choose new query , execute commandcreate login [iis apppool\defaultapppool] windows; exec sp_addsrvrolemember n'iis apppool\defaultapppool, sysadmin
Comments
Post a Comment