asp.net - Login and account registration broken on MVC application -
hello i'm new mvc , have been looking solution problem last couple days no avail.
i've created simple blog engine using asp.net mvc, after installing on iis on local pc, realized needed database login service work.
so elected use localdb on pc plan use server. moved files on pc , installed needed. installed sqlexpress localdb , reset site, working perfectly. however, noticed minor typos on section of site that's not edited. stupidly, reinstalled website entirely new build instead of updating view needed correction smart person do.
now every time attempt login excising account or create new 1 error
cannot attach file 'c:\inetpub\wwwroot\app_data\aspnet-facetblog-20161020065352.mdf' database 'aspnet-facetblog-20161020065352'.
from i've learned, it's localdb instance, fixes i've found online seem have no effect.
admittingly, i'm pretty naive comes sql, fix simple. if i've failed provide vital information please tell me , i'll update question. additionally, explanation of went wrong appreciated. thank time.
when reinstalling site, had deleted database file aspnet-facetblog-20161020065352.mdf
in database directory. since deleting mdf file doesn't affect registered sql express instance, sql express thinks database still exists , trying connect failed.
first, try attach db using ssms query this:
exec sp_attach_db @dbname=n'aspnet-facetblog-20161020065352.mdf', @filename1=n'app_data\aspnet-facetblog-20161020065352.mdf', @filename2=n'app_data\aspnet-facetblog-20161020065352.ldf'
nb: assumed mdf file location stands in app_data
directory, change actual database directory.
if attempt attach query doesn't work, try these steps:
- stop iis/iis express pool if still running.
- open windows powershell instance on server pc (install first if doesn't exist).
run following command:
sqllocaldb.exe stop v11.0 sqllocaldb.exe delete v11.0 sqllocaldb.exe start v11.0
recreate db instance on project, including data connection in server explorer (remove create).
- re-run project in development machine, copy required files server pc. database instance should (re-)generated @ time.
- restart iis/iis express pool on server pc.
additionally may run update-database
command package manager console ensure database integrity.
if solutions still won't work altogether, rename database files , attach on project, verify connection string retry step (5) , (6) above.
related problems:
ef5: cannot attach file ‘{0}' database '{1}'
cannot attach file ".mdf" database "aspnet-"
delete .mdf file app_data causes exception cannot attach file database
Comments
Post a Comment