asp.net mvc - .mdf file not able to attach at runtime MVC4 -


error:

cannot attach file 'c:\users\dboyle\desktop\new folder (2)\oilngasweb\oilngasweb\app_data\aspnet-mvcapplication4-20130726115749.mdf' database 'aspnet-mvcapplication4-20130726115749'.

*this error occured after deleting web.config file *( replacing new 1 new project , replacing default conection string needed)

edit:

sofar have tried deleting .mdf physical file , vs, sql. re-running update package manager within vs. database gets made, yet same error persists.

i have found

    <objectgroup name="defaultconnection" order="1" enabled="false">       <destination path="data source=ane-sql\anesqlserver;initial catalog=oilgas;user id=software;password=glvp$102" />       <object type="dbcodefirst">         <source path="dbmigration" dbcontext="oilngasweb.models.oilngasdb, oilngasweb" migrationconfiguration="oilngasweb.migrations.configuration, oilngasweb" origin="configuration" />       </object>    </objectgroup> 

in website.pubxml file ( still shows old database name ) interfier?

while doing database update using code-first migrations in asp.net mvc, came across strange exception , details follows,

issue ground details,

  1. manually deleted auto created ".mdf" file app_data folder using visual studio.

  2. executed update-database in package manager console. got below exception,

system.data.sqlclient.sqlexception (0x80131904): cannot attach file 'e:\backup\practice\mvc4\dotnetexamples\dotnetexamples\app_data\dotnetexamples.mdf' database 'dotnetexamples'.

solution:

if delete db file, still stays registered sqllocaldb. fixes deleting db. can command line.

open "developer command propmpt visualstudio" under "start/programs menu->all programs->visual studio 2012->visual studio tools"

run following commands:  sqllocaldb.exe stop v11.0  sqllocaldb.exe delete v11.0 

please have .mdf file , ssms instance of database deleted. execute "update-database" command package manager console , create database without obstacles.


Comments

Popular posts from this blog

php - get table cell data from and place a copy in another table -

javascript - Mootools wait with Fx.Morph start -

php - Navigate throught databse rows -