2017-03-05 8 views
0

Ich kann Migrationen aktivieren, aber ich kann DB nicht aktualisieren oder eine Migration hinzufügen. Wenn ich versuche zu deaktivieren - Migrationen, um dann wieder zu aktivieren ich bekomme "Der Begriff 'deaktivieren-Migrationen' wird nicht erkannt", habe ich versucht, das Entfernen des Pakets und Neuinstallation als Admin, Ändern von App.config Zeilen. Ich habe das gleiche Problem bei meiner Arbeit pc und mein Zuhause, habe ich eine Menge Beiträge hier gelesen und die Vorschläge haben mein Problem nicht behoben. egal, was ich tue, wenn es mir zu modifizieren immer diesen Fehler (Hinzufügen von Migration, db etc. Aktualisierung) kommtEntity Framework Migrationen Problem: DbMigrationsConfiguration '1 'hat eine Ausnahme ausgelöst

PM> add-migration TTT 
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 connectionString. (C:\Users\bern4rdo\Desktop\BasicEntityApp\tmp9260.tmp line 8) 
    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 BasicEntityApp.Migrations.Configuration..ctor() in C:\Users\bern4rdo\Desktop\BasicEntityApp\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.Run() 
    at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate) 
    at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate) 
    at System.Data.Entity.Migrations.Design.ToolingFacade.Run(BaseRunner runner) 
    at System.Data.Entity.Migrations.Design.ToolingFacade.Scaffold(String migrationName, String language, String rootNamespace, Boolean ignoreChanges) 
    at System.Data.Entity.Migrations.AddMigrationCommand.Execute(String name, Boolean force, Boolean ignoreChanges) 
    at System.Data.Entity.Migrations.AddMigrationCommand.<>c__DisplayClass2.<.ctor>b__0() 
    at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command) 
The type initializer for ***'System.Data.Entity.Migrations.DbMigrationsConfiguration`1' threw an exception.** 
PM>* 

ich die Datei, um sie in

C verweisen geprüft haben: \ Benutzer \ bern4rdo \ Desktop \ BasicEntityApp \ Migrations \ Configuration.cs: Zeile 10

Zeile 10 ist die Verbindungszeichenfolge. Ich habe die App-Konfigurationsdatei unten eingefügt, aber wenn ich in der Lage bin, eine gute Richtung zu bekommen, was als nächstes zu tun ist, würde ich es sehr schätzen. Ich habe Dinge wie Berechtigungen ausgeschlossen, IVE versucht, verschiedene Server etc

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <configSections> 
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> 
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> 
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> 
    </configSections> 
    <connectionString> 
    <add name="SalesContext" connectionstring="DataSource=BERNARDO\SQLEXPRESS; Initial Catalogue=BasicEntityApp; trusted security=true; trustedserverCertificate=false;" providername="System.Data.sqlClient" /> 
    </connectionString> 
    <startup> 
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /> 
    </startup> 
    <entityFramework> 
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlCeConnectionFactory, EntityFramework"> 
     <parameters> 
     <parameter value="System.Data.SqlServerCe.4.0" /> 
     </parameters> 
    </defaultConnectionFactory> 
    <providers> 
     <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> 
     <provider invariantName="System.Data.SqlServerCe.4.0" type="System.Data.Entity.SqlServerCompact.SqlCeProviderServices, EntityFramework.SqlServerCompact" /> 
    </providers> 
    </entityFramework> 
    <system.data> 

    <DbProviderFactories> 
     <remove invariant="System.Data.SqlServerCe.4.0" /> 
     <add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" /> 
    </DbProviderFactories> 
    </system.data> 
</configuration> 

Antwort

0

Ihre Config-Abschnitt falsch <connectionString> genannt wird, wenn es in der Tat sollte <connectionStrings> sein:

<connectionStrings> 
    <add name="SalesContext" connectionstring="DataSource=BERNARDO\SQLEXPRESS; Initial Catalogue=BasicEntityApp; trusted security=true; trustedserverCertificate=false;" providername="System.Data.sqlClient" /> 
</connectionStrings> 
+0

beide versuchten. Anfangs hatte es als connectionStrings:/werde es nochmal versuchen>. < – berni3mack

Verwandte Themen