[解決済み] Entity Frameworkです。プロバイダがprovideermanifestインスタンスを返さなかった
2022-02-28 07:20:25
質問
エンティティーフレームワーク 6.0.1 私のApp.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>
そして
MyDataContext
クラスは、EFを使用するためのものです。
public partial class MyDataContext: DbContext
{
static MyDataContext()
{
Database.SetInitializer<MyDataContext>(null);
}
public MyDataContext()
: base("MyDataContext")
{
}
}
コンテキストは作成されましたが、エンティティを取得したり、データベースで何かをしようとすると、例外がスローされます。
using (var db = new MyDataContext())
{
var exists = db.Database.Exists();
}
例外は
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()
を、内側の例外を除いて
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)
もしかしたら、どなたかこの問題に遭遇された方はいらっしゃいますか?ありがとうございます。
解決方法は?
この例外は、データベースへのログイン情報が有効でない場合、サーバーが見つからない場合、ファイアウォールの内側にある場合(基本的に、あなたのプログラムはデータベースに接続できません)にスローされる可能性があります。通常は、何が起こったかを詳しく説明する内部例外が付属しています。これを必ず確認してください。このエラーには他の原因もあるかもしれませんが、これが最も可能性の高いものだと思います。
また、SQL認証とWindows認証のどちらをお使いでしょうか?SQL認証を使っている場合は、Windowsに
integrated security=False
を接続文字列に追加してください。
関連
-
[解決済み】Sequence contains no matching element(シーケンスにマッチする要素がない
-
[解決済み】Swashbuckle/Swagger + ASP.Net Core: "Failed to load API definition" (API定義の読み込みに失敗しました
-
[解決済み】Unity 「関連するスクリプトを読み込むことができません」「Win32Exception: システムは指定されたファイルを見つけることができません"
-
[解決済み] [Solved] .NETでスレッドの終了を待つには?
-
[解決済み] 不変量名 'System.Data.SqlClient' を持つ ADO.NET プロバイダに対応する Entity Framework プロバイダが見つかりませんでした。
-
[解決済み] SQL Server の DateTime データ型から日付だけを返す方法
-
[解決済み] Entity FrameworkとLINQ to SQLの比較
-
[解決済み] Entity Frameworkにおける最速の挿入方法
-
[解決済み] Entity Frameworkで生成されたSQLを表示するにはどうすればよいですか?
-
[解決済み】Entity Frameworkプロバイダタイプをロードできませんでしたか?
最新
-
nginxです。[emerg] 0.0.0.0:80 への bind() に失敗しました (98: アドレスは既に使用中です)
-
htmlページでギリシャ文字を使うには
-
ピュアhtml+cssでの要素読み込み効果
-
純粋なhtml + cssで五輪を実現するサンプルコード
-
ナビゲーションバー・ドロップダウンメニューのHTML+CSSサンプルコード
-
タイピング効果を実現するピュアhtml+css
-
htmlの選択ボックスのプレースホルダー作成に関する質問
-
html css3 伸縮しない 画像表示効果
-
トップナビゲーションバーメニュー作成用HTML+CSS
-
html+css 実装 サイバーパンク風ボタン
おすすめ
-
[解決済み】スクリプトクラスが見つからないので、スクリプトコンポーネントを追加できない?
-
[解決済み】WebForms UnobtrusiveValidationModeは、jqueryのScriptResourceMappingを必要とする
-
[解決済み】文字列が有効な DateTime " format dd/MM/yyyy " として認識されなかった。
-
[解決済み】SmtpException: トランスポート接続からデータを読み取れません:net_io_connectionclosed
-
[解決済み】「namespace x already contains a definition for x」エラーの修正方法は?VS2010にコンバートした後に発生しました。
-
[解決済み】値が期待した範囲に収まらない
-
[解決済み】値をNULLにすることはできません。パラメータ名:source
-
[解決済み】ランダムなブーリアンを生成する最速の方法
-
VSでscanfエラーを恒久的に解決するには、ソースファイルを作成し、自動的に#define _CRT_SECURE_NO_WARNINGS 1を追加してください。
-
[解決済み】別のスレッドがこのオブジェクトを所有しているため、呼び出し側のスレッドはこのオブジェクトにアクセスできない