Click here to Skip to main content
15,438,920 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Team

I have enabled-migrations well and its running fine, when i try to add-migration it throws an exception
The type initializer for 'System.Data.Entity.Migrations.DbMigrationsConfiguration`1' threw an exception.


What I have tried:

M> Add-Migration eNtsaRegistration
C#

Posted
Comments
Richard Deeming 12-Mar-20 9:22am    
You'll need the details of the inner exception to know what the problem is. If you can't see the inner exception, try adding the -verbose parameter to the Add-Migration command:
Add-Migration eNtsaRegistration -Verbose
gcogco10 12-Mar-20 9:32am     CRLF
System.TypeInitializationException: The type initializer for 'System.Data.Entity.Migrations.DbMigrationsConfiguration`1' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.Data.Entity.Internal.AppConfig' threw an exception. ---> System.Configuration.ConfigurationErrorsException: Configuration system failed to initialize ---> System.Configuration.ConfigurationErrorsException: Unrecognized configuration section add. (C:\Users\gcobanim\source\repos\eNtsaRegistrationTraining\Web.config line 14) at System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean ignoreLocal) at System.Configuration.BaseConfigurationRecord.ThrowIfParseErrors(ConfigurationSchemaErrors schemaErrors) at System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey) --- End of inner exception stack trace --- at System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey) at System.Configuration.ClientConfigurationSystem.PrepareClientConfigSystem(String sectionName) at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String sectionName) at System.Configuration.ConfigurationManager.GetSection(String sectionName) at System.Configuration.ConfigurationManager.get_ConnectionStrings() at System.Data.Entity.Internal.AppConfig..ctor() at System.Data.Entity.Internal.AppConfig..cctor() --- End of inner exception stack trace --- at System.Data.Entity.Infrastructure.DependencyResolution.DbConfigurationManager.EnsureLoadedForAssembly(Assembly assemblyHint, Type contextTypeHint) at System.Data.Entity.Migrations.DbMigrationsConfiguration`1..cctor() --- End of inner exception stack trace --- at System.Data.Entity.Migrations.DbMigrationsConfiguration`1..ctor() at eNtsaRegistrationTraining.Migrations.Configuration..ctor() in C:\Users\gcobanim\source\repos\eNtsaRegistrationTraining\Migrations\Configuration.cs:line 13 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Data.Entity.Migrations.Utilities.MigrationsConfigurationFinder.FindMigrationsConfiguration(Type contextType, String configurationTypeName, Func`2 noType, Func`3 multipleTypes, Func`3 noTypeWithName, Func`3 multipleTypesWithName) at System.Data.Entity.Infrastructure.Design.Executor.GetMigrationsConfiguration(String migrationsConfigurationName) at System.Data.Entity.Infrastructure.Design.Executor.ScaffoldInternal(String name, DbConnectionInfo connectionInfo, String migrationsConfigurationName, Boolean ignoreChanges) at System.Data.Entity.Infrastructure.Design.Executor.Scaffold.<>c__DisplayClass0_0.<.ctor>b__0() at System.Data.Entity.Infrastructure.Design.Executor.OperationBase.<>c__DisplayClass4_0`1.<execute>b__0() at System.Data.Entity.Infrastructure.Design.Executor.OperationBase.Execute(Action action) The type initializer for 'System.Data.Entity.Migrations.DbMigrationsConfiguration`1' threw an exception.
gcogco10 12-Mar-20 9:35am    
You always my hero Richard, saw what was the issue by using that -verbose. I omit this <appsetting>
ZurdoDev 12-Mar-20 9:37am     CRLF
1. Reply to the comment so that the user is notified. 2. The error says you have something invalid in your config file.
gcogco10 12-Mar-20 9:38am    
ZurdoDev yes and its fixed. I was missing <appsetting>

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900