Home  /  Questions  /  Question



0   0
Feb 24, 2016


Is there anyone can help me to fix a problem regarding database setup with SQL Server in Pattern in Action.

Server Error in '/' Application. 


Invalid column name 'CompanyName'.
Invalid column name 'City'.
Invalid column name 'Country'.
 

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.

Exception Details: System.Data.SqlClient.SqlException: Invalid column name 'CompanyName'.
Invalid column name 'City'.
Invalid column name 'Country'.

Source Error:


Line 42:             using (var context = new actionEntities())

Line 43:             {

Line 44:                 var member = context.MemberEntities.FirstOrDefault(c => c.Email == email) as MemberEntity;

Line 45:                 return Mapper.Map<MemberEntity, Member>(member);

Line 46:             }


Source File: \\Mac\Home\Documents\Visual Studio 2015\Projects\DesignPatternFrameworkCS_4.5_1User\Patterns in Action\DataObjects\EntityFramework\MemberDao.cs Line: 44

Stack Trace:


[SqlException (0x80131904): Invalid column name 'CompanyName'.

Invalid column name 'City'.

Invalid column name 'Country'.]

   System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +2434922

   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +5736592

   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +285

   System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) +3731

   System.Data.SqlClient.SqlDataReader.TryConsumeMetaData() +58

   System.Data.SqlClient.SqlDataReader.get_MetaData() +89

   System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +379

   System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds, Boolean describeParameterEncryptionRequest) +2026

   System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite) +375

   System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) +53

   System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) +240

   System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) +41

   System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior) +12

   System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.<Reader>b__c(DbCommand t, DbCommandInterceptionContext`1 c) +14

   System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch(TTarget target, Func`3 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed) +72

   System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.Reader(DbCommand command, DbCommandInterceptionContext interceptionContext) +402

   System.Data.Entity.Internal.InterceptableDbCommand.ExecuteDbDataReader(CommandBehavior behavior) +166

   System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior) +12

   System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior) +36


[EntityCommandExecutionException: An error occurred while executing the command definition. See the inner exception for details.]

   System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior) +103

   System.Data.Entity.Core.Objects.Internal.ObjectQueryExecutionPlan.Execute(ObjectContext context, ObjectParameterCollection parameterValues) +758

   System.Data.Entity.Core.Objects.<>c__DisplayClass7.<GetResults>b__6() +90

   System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction(Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess) +288

   System.Data.Entity.Core.Objects.<>c__DisplayClass7.<GetResults>b__5() +154

   System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Func`1 operation) +190

   System.Data.Entity.Core.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption) +283

   System.Data.Entity.Core.Objects.ObjectQuery`1.<System.Collections.Generic.IEnumerable<T>.GetEnumerator>b__0() +15

   System.Data.Entity.Internal.LazyEnumerator`1.MoveNext() +45

   System.Linq.Enumerable.FirstOrDefault(IEnumerable`1 source) +121

   System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.<GetElementFunction>b__1(IEnumerable`1 sequence) +40

   System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.ExecuteSingle(IEnumerable`1 query, Expression queryRoot) +59

   System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.System.Linq.IQueryProvider.Execute(Expression expression) +114

   System.Data.Entity.Internal.Linq.DbQueryProvider.Execute(Expression expression) +116

   System.Linq.Queryable.FirstOrDefault(IQueryable`1 source, Expression`1 predicate) +249

   DataObjects.EntityFramework.MemberDao.GetMemberByEmail(String email) in \\Mac\Home\Documents\Visual Studio 2015\Projects\DesignPatternFrameworkCS_4.5_1User\Patterns in Action\DataObjects\EntityFramework\MemberDao.cs:44

   ActionService.Service.GetMemberByEmail(String email) in \\Mac\Home\Documents\Visual Studio 2015\Projects\DesignPatternFrameworkCS_4.5_1User\Patterns in Action\ActionService\Service.cs:72

   Mvc.MvcApplication.Application_Start() in \\Mac\Home\Documents\Visual Studio 2015\Projects\DesignPatternFrameworkCS_4.5_1User\Patterns in Action\Mvc\Global.asax.cs:33


[HttpException (0x80004005): An error occurred while executing the command definition. See the inner exception for details.]

   System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +9966013

   System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +118

   System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172

   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +352

   System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296


[HttpException (0x80004005): An error occurred while executing the command definition. See the inner exception for details.]

   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9947380

   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101

   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +261


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.1055.0