-
- Server Error in '/' Application.
- A file activation error occurred. The physical file name '[DataDirectory]\Firma.mdf' may be incorrect. Diagnose and correct additional errors, and retry the operation.
- CREATE DATABASE failed. Some file names listed could not be created. Check related errors.
- 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: A file activation error occurred. The physical file name '[DataDirectory]\Firma.mdf' may be incorrect. Diagnose and correct additional errors, and retry the operation.
- CREATE DATABASE failed. Some file names listed could not be created. Check related errors.
- Source Error:
- Line 16: public ActionResult Index()
- Line 17: {
- Line 18: var employee = db.Employees.ToList();
- Line 19:
- Line 20: return View(employee);
- Source File: c:\Users\Karen Goh\Documents\Visual Studio 2013\Projects\Company\Company\Controllers\TitleController.cs Line: 18
- Stack Trace:
- [SqlException (0x80131904): A file activation error occurred. The physical file name '[DataDirectory]\Firma.mdf' may be incorrect. Diagnose and correct additional errors, and retry the operation.
- CREATE DATABASE failed. Some file names listed could not be created. Check related errors.]
- System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +2435274
- System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +5736940
- 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.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout, Boolean asyncWrite) +940
- System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite) +272
- System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +280
- System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.
b__0(DbCommand t, DbCommandInterceptionContext`1 c) +10 - 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.NonQuery(DbCommand command, DbCommandInterceptionContext interceptionContext) +356
- System.Data.Entity.SqlServer.<>c__DisplayClass1a.
b__19(DbConnection conn) +119 - System.Data.Entity.SqlServer.<>c__DisplayClass33.
b__32() +443 - System.Data.Entity.SqlServer.<>c__DisplayClass1.
b__0() +10 - System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Func`1 operation) +189
- System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Action operation) +78
- System.Data.Entity.SqlServer.SqlProviderServices.UsingConnection(DbConnection sqlConnection, Action`1 act) +175
- System.Data.Entity.SqlServer.SqlProviderServices.UsingMasterConnection(DbConnection sqlConnection, Action`1 act) +556
- System.Data.Entity.SqlServer.SqlProviderServices.CreateDatabaseFromScript(Nullable`1 commandTimeout, DbConnection sqlConnection, String createDatabaseScript) +86
- System.Data.Entity.SqlServer.SqlProviderServices.DbCreateDatabase(DbConnection connection, Nullable`1 commandTimeout, StoreItemCollection storeItemCollection) +164
- System.Data.Entity.Core.Common.DbProviderServices.CreateDatabase(DbConnection connection, Nullable`1 commandTimeout, StoreItemCollection storeItemCollection) +76
- System.Data.Entity.Core.Objects.ObjectContext.CreateDatabase() +134
- System.Data.Entity.Migrations.Utilities.DatabaseCreator.Create(DbConnection connection) +119
- System.Data.Entity.Migrations.DbMigrator.EnsureDatabaseExists(Action mustSucceedToKeepDatabase) +142
- System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration) +78
- System.Data.Entity.Internal.DatabaseCreator.CreateDatabase(InternalContext internalContext, Func`3 createMigrator, ObjectContext objectContext) +89
- System.Data.Entity.Internal.InternalContext.CreateDatabase(ObjectContext objectContext, DatabaseExistenceState existenceState) +116
- System.Data.Entity.Database.Create(DatabaseExistenceState existenceState) +218
- System.Data.Entity.DropCreateDatabaseIfModelChanges`1.InitializeDatabase(TContext context) +181
- System.Data.Entity.Internal.<>c__DisplayClassf`1.
b__e() +76 - System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action) +60
- System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization() +357
- System.Data.Entity.Internal.LazyInternalContext.
b__4(InternalContext c) +7 - System.Data.Entity.Internal.RetryAction`1.PerformAction(TInput input) +110
- System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action`1 action) +198
- System.Data.Entity.Internal.LazyInternalContext.InitializeDatabase() +73
- System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) +28
- System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() +53
- System.Data.Entity.Internal.Linq.InternalSet`1.GetEnumerator() +15
- System.Data.Entity.Infrastructure.DbQuery`1.System.Collections.Generic.IEnumerable
.GetEnumerator() +53 - System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) +369
- System.Linq.Enumerable.ToList(IEnumerable`1 source) +58
- Company.Controllers.TitleController.Index() in c:\Users\Karen Goh Seow Hui\Documents\Visual Studio 2013\Projects\Company\Company\Controllers\TitleController.cs:18
- lambda_method(Closure , ControllerBase , Object[] ) +62
- System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +14
- System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +157
- System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
- System.Web.Mvc.Async.AsyncControllerActionInvoker.
b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState) +22 - System.Web.Mvc.Async.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult) +29
- System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
- System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +32
- System.Web.Mvc.Async.AsyncInvocationWithFilters.
b__3d() +50 - System.Web.Mvc.Async.<>c__DisplayClass46.
b__3f() +225 - System.Web.Mvc.Async.<>c__DisplayClass33.
b__32(IAsyncResult asyncResult) +10 - System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10
- System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
- System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +34
- System.Web.Mvc.Async.<>c__DisplayClass2b.
b__1c() +26 - System.Web.Mvc.Async.<>c__DisplayClass21.
b__1e(IAsyncResult asyncResult) +100 - System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10
- System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
- System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +27
- System.Web.Mvc.Controller.
b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +13 - System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29
- System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
- System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +36
- System.Web.Mvc.Controller.
b__15(IAsyncResult asyncResult, Controller controller) +12 - System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +22
- System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
- System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +26
- System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
- System.Web.Mvc.MvcHandler.
b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +21 - System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29
- System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
- System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +28
- System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
- System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9644097
- System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
- Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.1055
- .0
-
Loading
Tangara GPosted Jul 11, 2016, 10:41 AM
Tangara GPosted Jul 11, 2016, 8:24 AM
Rajeev PunhaniPosted Jul 11, 2016, 8:15 AM
Hi Karen,
This error occurs when you are trying to insert the data in the child table foriegn key which is not exists in the parent tables primary key. Please check the same.
Tangara GPosted Jul 11, 2016, 8:08 AM
And now I got this error :
Rajeev PunhaniPosted Jul 11, 2016, 2:50 AM
Hi Karen,
Please add the below code to your DatabaseContext Constructor.
If the above solution is helpful then,accept the answer.
kalu singh raoPosted Jul 11, 2016, 2:26 AM