Add Controller database error in ASP.NET MVC 4

johnny10119

New Member
When using the Add Controller helper/scaffolder with Entity Framework CRUD integration, I get the following error:\[code\]Unable to retrieve metadata for 'MyApp.Models.MyModel'. Cannot attach the file 'C:\Users\Lev\AppData\Local\Temp\2d7daf19-d47f-df24-ac76-d3df4fg2sa\aspnet-MyApp-20130409170533.mdf' as database 'aspnet-MyApp-20130409170533.mdf'.\[/code\]The question is: Why is it looking for the database in my temp files? The database file is located in:\[code\]C:\Projects\MyApp\MyApp\App_Data\[/code\]This is my connection string:\[code\]Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-MyApp-20130409170533;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-MyApp-20130409170533.mdf\[/code\]And so it seems that the reference to |DataDirectory| is misbehaving. How can I set DataDirectory?If I manually put the correct path into the AttachDBFilename property, then the scaffolding works. But I'd still love to leave it as |DataDirectory|.
 
Back
Top