I followed this tutorial when learning SQL Azure and completed it successfully: Windows Azure Tutorial
I wanted to create a similar application but implement a more complex database using the code first approach and upon typing the 'update-database' command I am getting the following error:
Cannot attach the file 'c:\users\dadler\documents\visual studio 2012\Projects\EliteTrainingAzure\EliteTrainingAzure\App_Data\EliteTrainingAzure.Models.EliteTrainingDB.mdf' as database 'EliteTrainingAzure.Models.EliteTrainingDB'.
Here is my connection string:
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-EliteTrainingAzure-20130325095843;User Intance = True;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-EliteTrainingAzure-20130325095843.mdf" providerName="System.Data.SqlClient"/>
And finally here is an example of how I handled the Foreign Key Creation:
namespace EliteTrainingAzure.Models
{ public class Client { [Key] public int ClientID { get; set; }
public int GoalID { get; set; }
[ForeignKey("GoalID")]
public Goal Goal { get; set; }
public int TrainerID { get; set; }
[ForeignKey("TrainerID")]
public Trainer Trainer { get; set; }
public string ClientName {get; set;}
public string ClientAddress { get; set; }
public string ClientCity { get; set; }
public string ClientState { get; set; }
public string ClientZip { get; set; }
If anyone could point me in the right direction as to how to fix this error that would be great. Thanks in advance!