0

I am trying to deploy a MVC Application on the IIS server. I have shared the sqllocaldb using command prompt and created a Private LocalDB instance with name IIS_DB

I have also changed the connection string in my Web.Config file to

 <add name="DefaultConnection" connectionString="Data Source=(LocalDb)\.\IIS_DB;Initial Catalog=aspnet-MvcApplication26-20141226150050;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-MvcApplication26-20141226150050.mdf" providerName="System.Data.SqlClient" />

As of now I can view the Home Page when I click on Browse from the ISS Manager.

But when I click on the Register/Login hyperlink, I get the following error

Cannot attach the file 'C:\inetpub\wwwroot\MvcApplication26\App_Data\aspnet-MvcApplication26-20141226150050.mdf' as database 'aspnet-MvcApplication26-20141226150050'.

2 Answers 2

1

I finally solved this by manually copying the APP_Data folder from Visual Studio to the my application directory on the IIS server

Sign up to request clarification or add additional context in comments.

Comments

0

After sharing the database here is what you have to do
Go to visual studio => databaseexplorer => add connection
For the server name enter (LocalDb).\IIS_DB then right click on the connection and choose new query and execute this command:
create login [IIS APPPool\DefaultAPPPool] from windows; exec sp_addsrvrolemember N'IIS APPPool\DefaultAPPPool, sysadmin

1 Comment

Already Done that I still get the same error Cannot attach the file 'C:\inetpub\wwwroot\MvcApplication26\App_Data\aspnet-MvcApplication26-20141226150050.mdf' as database 'aspnet-MvcApplication26-20141226150050'.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.