Entity Framework: Le fournisseur n'a pas retourné un providermanifest exemple
Entity Framework 6.0.1
mon Application.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
</startup>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<connectionStrings>
<add name="MyDataContext" connectionString="Data Source=MyDb;Initial Catalog=mycatalog;Persist Security Info=True;User ID=admin;Password=123;MultipleActiveResultSets=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
Et MyDataContext
classe pour l'utilisation de EF:
public partial class MyDataContext: DbContext
{
static MyDataContext()
{
Database.SetInitializer<MyDataContext>(null);
}
public MyDataContext()
: base("MyDataContext")
{
}
}
Un contexte est créé, mais quand j'ai essayé d'obtenir toute entité ou de faire quoi que ce soit avec la Base de données il jeter l'exception
using (var db = new MyDataContext())
{
var exists = db.Database.Exists();
}
exception est
System.Data.ProviderIncompatibleException: The provider did not return a providermanifest instance
StackTrace:
in System.Data.Common.DbProviderServices.GetProviderManifest(String manifestToken)
in System.Data.Entity.ModelConfiguration.Utilities.DbConnectionExtensions.GetProviderInfo(DbConnection connection, DbProviderManifest& providerManifest)
in System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection)
in System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext)
in System.Data.Entity.Internal.RetryLazy`2.GetValue(TInput input)
in System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
in System.Data.Entity.Internal.InternalContext.CreateObjectContextForDdlOps()
in System.Data.Entity.Database.Exists()
à l'intérieur d'exception:
System.Configuration.ConfigurationErrorException: Configuration system failed to initialize
StackTrace:
в System.Configuration.ClientConfigurationSystem.OnConfigRemoved(Object sender, InternalConfigEventArgs e)
в System.Configuration.Internal.InternalConfigRoot.RemoveConfigImpl(String configPath, BaseConfigurationRecord configRecord)
в System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
в System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
в System.Configuration.ConfigurationManager.GetSection(String sectionName)
в System.Xml.Schema.Parser..ctor(SchemaType schemaType, XmlNameTable nameTable, SchemaNames schemaNames, ValidationEventHandler eventHandler)
в System.Xml.Schema.XmlSchema.Read(XmlReader reader, ValidationEventHandler validationEventHandler)
в System.Data.Entity.Core.SchemaObjectModel.Schema.SomSchemaSetHelper.AddXmlSchemaToSet(XmlSchemaSet schemaSet, XmlSchemaResource schemaResource, HashSet`1 schemasAlreadyAdded)
в System.Data.Entity.Core.SchemaObjectModel.Schema.SomSchemaSetHelper.ComputeSchemaSet(SchemaDataModelOption dataModel)
в System.Data.Entity.Core.Common.Utils.Memoizer`2.<>c__DisplayClass2.<Evaluate>b__0()
в System.Data.Entity.Core.Common.Utils.Memoizer`2.Result.GetValue()
в System.Data.Entity.Core.Common.Utils.Memoizer`2.Evaluate(TArg arg)
в System.Data.Entity.Core.SchemaObjectModel.Schema.SomSchemaSetHelper.GetSchemaSet(SchemaDataModelOption dataModel)
в System.Data.Entity.Core.SchemaObjectModel.Schema.CreateXmlReaderSettings()
в System.Data.Entity.Core.SchemaObjectModel.Schema.Parse(XmlReader sourceReader, String sourceLocation)
в System.Data.Entity.Core.SchemaObjectModel.SchemaManager.ParseAndValidate(IEnumerable`1 xmlReaders, IEnumerable`1 sourceFilePaths, SchemaDataModelOption dataModel, AttributeValueNotification providerNotification, AttributeValueNotification providerManifestTokenNotification, ProviderManifestNeeded providerManifestNeeded, IList`1& schemaCollection)
в System.Data.Entity.Core.SchemaObjectModel.SchemaManager.ParseAndValidate(IEnumerable`1 xmlReaders, IEnumerable`1 sourceFilePaths, SchemaDataModelOption dataModel, DbProviderManifest providerManifest, IList`1& schemaCollection)
в System.Data.Entity.Core.SchemaObjectModel.SchemaManager.LoadProviderManifest(XmlReader xmlReader, String location, Boolean checkForSystemNamespace, Schema& schema)
в System.Data.Entity.Core.Common.DbXmlEnabledProviderManifest.Load(XmlReader reader)
в System.Data.Entity.Core.Common.DbXmlEnabledProviderManifest..ctor(XmlReader reader)
в System.Data.Entity.SqlServer.SqlProviderManifest..ctor(String manifestToken)
в System.Data.Entity.SqlServer.SqlProviderServices.GetDbProviderManifest(String versionHint)
в System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifest(String manifestToken)
and it with inner exception:
System.Configuration.ConfigurationErrorException: Unknown configuration section userSettings. (C:\\Users\\Tema\\AppData\\Local\\Mgr\\Mgr.vshost.exe_Url_slqi2aqp0duilazpy21vojhl3ssnjluh\\1.0.0.0\\user.config line 3)
StackTrace:
в System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean ignoreLocal)
в System.Configuration.BaseConfigurationRecord.ThrowIfParseErrors(ConfigurationSchemaErrors schemaErrors)
в System.Configuration.ClientConfigurationSystem.OnConfigRemoved(Object sender, InternalConfigEventArgs e)
Peut-être que quelqu'un a rencontré ce problème? Merci.
- J'ai juste supprimé le fichier avec UserSettings
C:\\Users\\Tema\\AppData\\Local\\Mgr\\Mgr.vshost.exe_Url_slqi2aqp0duilazpy21vojhl3ssnjluh\\1.0.0.0\\user.config
et il a résolu mon problème
Vous devez vous connecter pour publier un commentaire.
Cette exception peut être levée si les informations de connexion pour la base de données n'est pas valide ou si le serveur n'est pas trouvé ou se trouve derrière un pare-feu (en gros, votre programme ne peut pas se connecter à la base de données). Habituellement, il est livré avec un intérieur d'exception qui va vous en dire plus sur ce qui s'est passé. Assurez-vous de vérifier cela. Il peut y avoir d'autres causes possibles de cette erreur, mais c'est le plus probable, je pense.
Aussi, êtes-vous à l'aide de SQL ou de l'authentification Windows? Si vous utilisez l'authentification SQL, essayez d'ajouter
integrated security=False
à votre chaîne de connexion.integrated security=False
mais j'ai toujours eu cette erreurdata source=
est correct dans votre chaîne de connexion?MyDb
sonne comme le nom de base de données, mais ce doit être le nom de l'ordinateur et de l'instance du serveur (quelque chose commemydbserver\sqlexpress
). Aussi, essayez de vous connecter à la base de données avec les mêmes informations d'identification et à partir du même ordinateur avec quelque chose comme SQL Server Management Studio. Si cela ne fonctionne pas, ce ne le sera probablement jamais.Configuration system failed to initialize
Dans mon cas, j'ai eu de pirater le .Fichier EDMX et modifier le ProviderManifestToken="2008"
Changé le ProviderManifestToken valeur de l'attribut à partir de 2012 et 2008 et tout a bien fonctionné.
N'oubliez pas d'ouvrir l' .fichier edmx comme un fichier XML