title: Deploying MVC 4 to Azure Web Site with SQL db
body: <p>I just deployed my first Azure Web Site form a ASP.NET MVC 4 internet application template.  The application worked well on my local computer.  I followed the tutorial found here to deploy the web site:</p>
  
  <p><a href="http://www.windowsazure.com/en-us/develop/net/tutorials/web-site-with-sql-database/" rel="nofollow">http://www.windowsazure.com/en-us/develop/net/tutorials/web-site-with-sql-database/</a></p>
  
  <p>After deploying the site I can go the the website home page, my home controller does not require authentication.  When I try to log in I am directed to an error page.</p>
  
  <p>I modified my web.config file to get a custom error message and I receive this:</p>
  
  <blockquote>
    <p>There is already an object named 'UserProfile' in the database.</p>
    
    <p>Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. </p>
    
    <p>Exception Details: System.Data.SqlClient.SqlException: There is already an object named 'UserProfile' in the database.</p>
    
    <p>Source Error: </p>
    
    <p>An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.</p>
    
    <p>Stack Trace: </p>
    
    <p>[SqlException (0x80131904): There is already an object named 'UserProfile' in the database.]
       System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action<code>1 wrapCloseInAction) +1753346
       System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action</code>1 wrapCloseInAction) +5295154
       System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +242
       System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean&amp; dataReady) +1682
       System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout) +280
       System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource<code>1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite) +405
       System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +160
       System.Data.Entity.Migrations.DbMigrator.ExecuteSql(DbTransaction transaction, MigrationStatement migrationStatement) +125
       System.Data.Entity.Migrations.DbMigrator.ExecuteStatements(IEnumerable</code>1 migrationStatements) +113
       System.Data.Entity.Migrations.DbMigrator.ExecuteOperations(String migrationId, XDocument targetModel, IEnumerable<code>1 operations, Boolean downgrading, Boolean auto) +672
       System.Data.Entity.Migrations.DbMigrator.ApplyMigration(DbMigration migration, DbMigration lastMigration) +267
       System.Data.Entity.Migrations.DbMigrator.Upgrade(IEnumerable</code>1 pendingMigrations, String targetMigrationId, String lastMigrationId) +133
       System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration) +455
       System.Data.Entity.MigrateDatabaseToLatestVersion<code>2.InitializeDatabase(TContext context) +62
       System.Data.Entity.&lt;&gt;c__DisplayClass2</code>1.b_<em>0(DbContext c) +70
       System.Data.Entity.Internal.&lt;>c</em>_DisplayClass8.b_<em>6() +19
       System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action) +60
       System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization() +181
       System.Data.Entity.Internal.LazyInternalContext.b</em>_4(InternalContext c) +7
       System.Data.Entity.Internal.RetryAction<code>1.PerformAction(TInput input) +110
       System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action</code>1 action) +185
       System.Data.Entity.Internal.LazyInternalContext.InitializeDatabase() +73
       System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) +28
       System.Data.Entity.Internal.Linq.InternalSet<code>1.Initialize() +52
       System.Data.Entity.Internal.Linq.InternalSet</code>1.get_InternalContext() +15
       System.Data.Entity.Internal.Linq.InternalSet<code>1.Find(Object[] keyValues) +23
       EnergyToolbase.Controllers.AccountController.Login(LoginModel model, String returnUrl) +94
       lambda_method(Closure , ControllerBase , Object[] ) +147
       System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +14
       System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary</code>2 parameters) +182
       System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary<code>2 parameters) +27
       System.Web.Mvc.Async.&lt;&gt;c__DisplayClass42.&lt;BeginInvokeSynchronousActionMethod&gt;b__41() +28
       System.Web.Mvc.Async.&lt;&gt;c__DisplayClass8</code>1.b__7(IAsyncResult <em>) +10
       System.Web.Mvc.Async.WrappedAsyncResult<code>1.End() +50
       System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +32
       System.Web.Mvc.Async.&lt;&gt;c__DisplayClass39.&lt;BeginInvokeActionMethodWithFilters&gt;b__33() +58
       System.Web.Mvc.Async.&lt;&gt;c__DisplayClass4f.&lt;InvokeActionMethodFilterAsynchronously&gt;b__49() +225
       System.Web.Mvc.Async.&lt;&gt;c__DisplayClass4f.&lt;InvokeActionMethodFilterAsynchronously&gt;b__49() +225
       System.Web.Mvc.Async.&lt;&gt;c__DisplayClass37.&lt;BeginInvokeActionMethodWithFilters&gt;b__36(IAsyncResult asyncResult) +10
       System.Web.Mvc.Async.WrappedAsyncResult</code>1.End() +50
       System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +34
       System.Web.Mvc.Async.&lt;>c</em>_DisplayClass2a.b_<em>20() +24
       System.Web.Mvc.Async.&lt;>c</em>_DisplayClass25.b_<em>22(IAsyncResult asyncResult) +99
       System.Web.Mvc.Async.WrappedAsyncResult<code>1.End() +50
       System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +27
       System.Web.Mvc.&lt;&gt;c__DisplayClass1d.&lt;BeginExecuteCore&gt;b__18(IAsyncResult asyncResult) +14
       System.Web.Mvc.Async.&lt;&gt;c__DisplayClass4.&lt;MakeVoidDelegate&gt;b__3(IAsyncResult ar) +23
       System.Web.Mvc.Async.WrappedAsyncResult</code>1.End() +55
       System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +39
       System.Web.Mvc.Async.&lt;>c</em>_DisplayClass4.b__3(IAsyncResult ar) +23
       System.Web.Mvc.Async.WrappedAsyncResult<code>1.End() +55
       System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +29
       System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
       System.Web.Mvc.&lt;&gt;c__DisplayClass8.&lt;BeginProcessRequest&gt;b__3(IAsyncResult asyncResult) +25
       System.Web.Mvc.Async.&lt;&gt;c__DisplayClass4.&lt;MakeVoidDelegate&gt;b__3(IAsyncResult ar) +23
       System.Web.Mvc.Async.WrappedAsyncResult</code>1.End() +55
       System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +31
       System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
       System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()+9629708
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously) +155</p>
  </blockquote>
  
  <p>Can someone please point help me find the issue here.</p>