Lỗi add-migration create-db với code first

  • 57 lượt xem
  • Bài cuối 08 Tháng Sáu 2018
lâm tú đăng này 07 Tháng Sáu 2018

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 conectionStrings. (D:\DE-MS-Tu\Week1-2\Blogspots\Blogspot\tmpDED3.tmp line 85)

   at System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean ignoreLocal)

   at System.Configuration.BaseConfigurationRecord.ThrowIfParseErrors(ConfigurationSchemaErrors schemaErrors)

   at System.Configuration.BaseConfigurationRecord.ThrowIfInitErrors()

   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.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.Infrastructure.DependencyResolution.DbConfigurationManager.EnsureLoadedForContext(Type contextType)

   at System.Data.Entity.Migrations.DbMigrationsConfiguration`1..cctor()

   --- End of inner exception stack trace ---

   at System.Data.Entity.Migrations.DbMigrationsConfiguration`1..ctor()

   at Blogspot.Migrations.Configuration..ctor() in D:\DE-MS-Tu\Week1-2\Blogspots\Blogspot\Migrations\Configuration.cs:line 10

--- 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.Migrations.Design.ToolingFacade.BaseRunner.FindConfiguration()

   at System.Data.Entity.Migrations.Design.ToolingFacade.ScaffoldRunner.RunCore()

   at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.Run()

The type initializer for 'System.Data.Entity.Migrations.DbMigrationsConfiguration`1' threw an exception.

admin đăng này 08 Tháng Sáu 2018

Ở đây nó không nhận được cái chuỗi connection string trong App.Config

Bạn pải set startup project là cái project data nhé

TEDU

Close