none
modal compatibility issue in Code First approach

    Question

  • I have been practicing the MVC from code project and it shows an error in this project after lab 14.

    error is coming like this:

    Model compatibility cannot be checked because the database does not contain model metadata. Model compatibility can only be checked for databases created using Code First or Code First Migrations.

    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.NotSupportedException: Model compatibility cannot be checked because the database does not contain model metadata. Model compatibility can only be checked for databases created using Code First or Code First Migrations.

    Source Error: 
    Line 23:         {
    Line 24:             SalesERPDAL salesDal = new SalesERPDAL();
    Line 25:             return salesDal.Employees.ToList();
    Line 26:         }
    Line 27: 

    Source File: c:\Users\Rdas\Desktop\jdayma\MvcApplication3\MvcApplication3\Models\EmployeeBusinessLayer.cs    Line: 25 

    Stack Trace: 

    [NotSupportedException: Model compatibility cannot be checked because the database does not contain model metadata. Model compatibility can only be checked for databases created using Code First or Code First Migrations.] System.Data.Entity.Internal.ModelCompatibilityChecker.CompatibleWithModel(InternalContext internalContext, ModelHashCalculator modelHashCalculator, Boolean throwIfNoMetadata, DatabaseExistenceState existenceState) +251 System.Data.Entity.Internal.InternalContext.CompatibleWithModel(Boolean throwIfNoMetadata, DatabaseExistenceState existenceState) +54 System.Data.Entity.DropCreateDatabaseIfModelChanges`1.InitializeDatabase(TContext context) +120 System.Data.Entity.Internal.<>c__DisplayClassf`1.<CreateInitializationAction>b__e() +76 System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action) +60 System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization() +357 System.Data.Entity.Internal.LazyInternalContext.<InitializeDatabase>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.Initialize() +30 System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) +16 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<TResult>.GetEnumerator() +53 System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) +375 System.Linq.Enumerable.ToList(IEnumerable`1 source) +58 MvcApplication3.Models.EmployeeBusinessLayer.GetEmployees() in c:\Users\Rdas\Desktop\jdayma\MvcApplication3\MvcApplication3\Models\EmployeeBusinessLayer.cs:25 MvcApplication3.Controllers.EmployeeController.Index() in c:\Users\Rdas\Desktop\jdayma\MvcApplication3\MvcApplication3\Controllers\EmployeeController.cs:21 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) +182 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27 System.Web.Mvc.Async.<>c__DisplayClass42.<BeginInvokeSynchronousActionMethod>b__41() +28 System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +10 System.Web.Mvc.Async.WrappedAsyncResult`1.End() +50 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +32 System.Web.Mvc.Async.<>c__DisplayClass39.<BeginInvokeActionMethodWithFilters>b__33() +58 System.Web.Mvc.Async.<>c__DisplayClass4f.<InvokeActionMethodFilterAsynchronously>b__49() +228 System.Web.Mvc.Async.<>c__DisplayClass37.<BeginInvokeActionMethodWithFilters>b__36(IAsyncResult asyncResult) +10 System.Web.Mvc.Async.WrappedAsyncResult`1.End() +50 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +34 System.Web.Mvc.Async.<>c__DisplayClass2a.<BeginInvokeAction>b__20() +24 System.Web.Mvc.Async.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult asyncResult) +99 System.Web.Mvc.Async.WrappedAsyncResult`1.End() +50 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +27 System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__18(IAsyncResult asyncResult) +14 System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +16 System.Web.Mvc.Async.WrappedAsyncResult`1.End() +50 System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +36 System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +16 System.Web.Mvc.Async.WrappedAsyncResult`1.End() +50 System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +26 System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10 System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult) +25 System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +16 System.Web.Mvc.Async.WrappedAsyncResult`1.End() +50 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() +9987265 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155

    Wednesday, April 3, 2019 8:12 AM

All replies