この質問はこれまで何度も質問されて解決されており、このような役立つ投稿がたくさんあることを認識しています... http://blogs.teamb.com/craigstuntz/2010/08/13/38628/ しかし、残念ながらどれもうまくいかなかったので、誰かが私が見たことのないものを見つけてくれることを期待して投稿しています。
データベースプロジェクトSp_CodeGeneratorがあります-データベースに接続しました。私の接続文字列は
<add name="AdWorksLTEntities" connectionString="metadata=res://*/Sp_CodeGenerator.Model1.csdl|res://*/Sp_CodeGenerator.Model1.ssdl|res://*/Sp_CodeGenerator.Model1.msl;provider=System.Data.SqlClient;provider connection string="Data Source=EIRCOM;Initial Catalog=AdventureWorksLT2008R2;Integrated Security=True;MultipleActiveResultSets=True;Application Name=EntityFramework"" providerName="System.Data.EntityClient"/>
//*/Sp_CodeGenerator.Model...
dllなどの名前に置き換えてみましたが、うまくいき//Sp_CodeGenerator/Sp_CodeGenerator.Model.csdl
ません。
また、.configファイル内のすべての参照を削除し、.edmxファイルとEntity Frameworksによって生成され、何度も起動したテンプレートファイルを削除しましたが、機能しません。
ディレクトリ構造で、edmxファイル:Model1.csdl、Model1.msl、Model1.ssdlがedmxResourcesToEmbedというフォルダーに格納されており、C:\ Sp_CodeGenerator \ Sp_CodeGenerator \ obj\x86にあることがわかります。
したがって、フルパスはC:\ Sp_CodeGenerator \ Sp_CodeGenerator \ obj \ x86 \ Debug \ edmxResourcesToEmbed
偶然かどうかはわかりませんが、問題が発生すると、要素'entityFramework''defaultconnectionFactory''type'などのスキーマが欠落していることについて.configファイルを開くといくつかのメッセージが表示されることにも気付きました。
次にどこを見るべきかについての提案は、大歓迎です。
MetadataExceptionの完全なスタックトレースは
at System.Data.Metadata.Edm.MetadataArtifactLoaderResource.LoadResource()
at System.Data.Metadata.Edm.MetadataArtifactLoaderResource.CreateReader()
at System.Data.Metadata.Edm.MetadataArtifactLoaderResource.CreateReaders(DataSpace spaceToGet)
at System.Data.Metadata.Edm.MetadataArtifactLoaderComposite.CreateReaders(DataSpace spaceToGet)
at System.Data.Metadata.Edm.MetadataCache.EdmMetadataEntry.LoadEdmItemCollection(MetadataArtifactLoader loader)
at System.Data.Metadata.Edm.MetadataCache.EdmItemCollectionLoader.LoadItemCollection(EdmMetadataEntry entry)
at System.Data.Metadata.Edm.MetadataCache.LoadItemCollection[T](IItemCollectionLoader`1 itemCollectionLoader, T entry)
at System.Data.Metadata.Edm.MetadataCache.GetOrCreateEdmItemCollection(String cacheKey, MetadataArtifactLoader loader, Object& entryToken)
at System.Data.EntityClient.EntityConnection.LoadEdmItemCollection(MetadataWorkspace workspace, MetadataArtifactLoader artifactLoader)
at System.Data.EntityClient.EntityConnection.GetMetadataWorkspace(Boolean initializeAllCollections)
at System.Data.Objects.ObjectContext.RetrieveMetadataWorkspaceFromConnection()
at System.Data.Objects.ObjectContext..ctor(EntityConnection connection, Boolean isConnectionConstructor)
at System.Data.Objects.ObjectContext..ctor(EntityConnection connection)
at System.Data.Entity.Internal.InternalConnection.CreateObjectContextFromConnectionModel()
at System.Data.Entity.Internal.LazyInternalConnection.CreateObjectContextFromConnectionModel()
at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
at System.Data.Entity.Internal.InternalContext.Initialize()
at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)
at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()
at System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext()
at System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider()
at System.Linq.Queryable.OrderBy[TSource,TKey](IQueryable`1 source, Expression`1 keySelector)
at Sp_CodeGenerator.SelectAll.SelectAll_Method() in C:\Sp_CodeGenerator\Sp_CodeGenerator\Templates\dbo.SelectAll.StoredProcedure.sql.xml.cs:line 14
at Sp_CodeGenerator.Program.Main(String[] args) in C:\Sp_CodeGenerator\Sp_CodeGenerator\Program.cs:line 15
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()