1

MySQL でテーブルをセットアップし、サーバー エクスプローラーで接続を追加し、正しいアセンブリを追加し、適切な ADO.NET エンティティ モデルを作成し、正しい app.config ファイルを確保しました。データベースに保存するときに、次のコードを実行しています。

MySQLEntity MySQLDB= new MySQLEntity();
mysqlspectra DBSPectra = new mysqlspectra();
DBSPectra.DateTime = DateTime.Now;
DBSPectra.Name = null;
DBSPectra.Version = spectra.Info.Version;
DBSPectra.SerialHighNumber = spectra.Info.SerialHighNumber;
DBSPectra.SerialLowNumber = spectra.Info.SerialLowNumber;
DBSPectra.Completed = spectra.Info.Completed;
DBSPectra.SpectrometerID = spectra.Info.SpectrometerID;
DBSPectra.GasCellID = spectra.Info.GasCellID;
DBSPectra.Format = (short)spectra.Info.Format;
DBSPectra.Apodization = (short)spectra.Info.Apodization;
DBSPectra.PhaseApodization = (short)spectra.Info.PhaseApodization;
DBSPectra.Temperature = spectra.Info.Temperature;
DBSPectra.Pressure = spectra.Info.Pressure;
DBSPectra.NumScans = spectra.Info.NumScans;
DBSPectra.Resolution = spectra.Info.Resolution;
DBSPectra.Gain = spectra.Info.Gain;
DBSPectra.PathLength = spectra.Info.PathLength;
DBSPectra.FirstPoint = spectra.Info.FirstPoint;
DBSPectra.LastPoint = spectra.Info.LastPoint;
DBSPectra.MaxFrequency = spectra.Info.MaxFrequency;
DBSPectra.MaxLocPoint = spectra.Info.MaxLocPoint;
DBSPectra.MinLocPoint = spectra.Info.MinLocPoint;
DBSPectra.NumDataPoints = spectra.Info.NumDataPoints;
DBSPectra.NumDataPhase = spectra.Info.NumDataPhase;
DBSPectra.Step = spectra.Info.Step;
DBSPectra.IgramType = (short)spectra.Info.IgramType;
DBSPectra.DataPoints = GetBytes(spectra.DataPoints);
MySQLDB.mysqlspectras.AddObject(DBSPectra);
MySQLDB.SaveChanges();

キャッチされた例外からのスタック トレースは次のとおりです。

   at MySql.Data.MySqlClient.MySqlClientFactory.get_MySqlDbProviderServicesInstance()
   at MySql.Data.MySqlClient.MySqlClientFactory.System.IServiceProvider.GetService(Type serviceType)
   at System.Data.Common.DbProviderServices.GetProviderServices(DbProviderFactory factory)
   at System.Data.Metadata.Edm.StoreItemCollection.Loader.InitializeProviderManifest(Action3 addError)
   at System.Data.Metadata.Edm.StoreItemCollection.Loader.OnProviderManifestTokenNotification(String token, Action3 addError)
   at System.Data.EntityModel.SchemaObjectModel.Schema.HandleProviderManifestTokenAttribute(XmlReader reader)
   at System.Data.EntityModel.SchemaObjectModel.Schema.HandleAttribute(XmlReader reader)
   at System.Data.EntityModel.SchemaObjectModel.SchemaElement.ParseAttribute(XmlReader reader)
   at System.Data.EntityModel.SchemaObjectModel.SchemaElement.Parse(XmlReader reader)
   at System.Data.EntityModel.SchemaObjectModel.Schema.HandleTopLevelSchemaElement(XmlReader reader)
   at System.Data.EntityModel.SchemaObjectModel.Schema.InternalParse(XmlReader sourceReader, String sourceLocation)
   at System.Data.EntityModel.SchemaObjectModel.Schema.Parse(XmlReader sourceReader, String sourceLocation)
   at System.Data.EntityModel.SchemaObjectModel.SchemaManager.ParseAndValidate(IEnumerable1 xmlReaders, IEnumerable1 sourceFilePaths, SchemaDataModelOption dataModel, AttributeValueNotification providerNotification, AttributeValueNotification providerManifestTokenNotification, ProviderManifestNeeded providerManifestNeeded, IList1& schemaCollection)
   at System.Data.Metadata.Edm.StoreItemCollection.Loader.LoadItems(IEnumerable1 xmlReaders, IEnumerable1 sourceFilePaths)
   at System.Data.Metadata.Edm.StoreItemCollection.Init(IEnumerable1 xmlReaders, IEnumerable1 filePaths, Boolean throwOnError, DbProviderManifest& providerManifest, DbProviderFactory& providerFactory, String& providerManifestToken, Memoizer`2& cachedCTypeFunction)
   at System.Data.Metadata.Edm.StoreItemCollection..ctor(IEnumerable1 xmlReaders, IEnumerable1 filePaths)
   at System.Data.Metadata.Edm.MetadataCache.StoreMetadataEntry.LoadStoreCollection(EdmItemCollection edmItemCollection, MetadataArtifactLoader loader)
   at System.Data.Metadata.Edm.MetadataCache.StoreItemCollectionLoader.LoadItemCollection(StoreMetadataEntry entry)
   at System.Data.Metadata.Edm.MetadataCache.LoadItemCollection[T](IItemCollectionLoader1 itemCollectionLoader, T entry)
   at System.Data.Metadata.Edm.MetadataCache.GetOrCreateStoreAndMappingItemCollections(String cacheKey, MetadataArtifactLoader loader, EdmItemCollection edmItemCollection, Object& entryToken)
   at System.Data.EntityClient.EntityConnection.LoadStoreItemCollections(MetadataWorkspace workspace, DbConnection storeConnection, DbProviderFactory factory, DbConnectionOptions connectionOptions, EdmItemCollection edmItemCollection, MetadataArtifactLoader artifactLoader)
   at System.Data.EntityClient.EntityConnection.GetMetadataWorkspace(Boolean initializeAllCollections)
   at System.Data.EntityClient.EntityConnection.InitializeMetadata(DbConnection newConnection, DbConnection originalConnection, Boolean closeOriginalConnectionOnFailure)
   at System.Data.EntityClient.EntityConnection.Open()
   at System.Data.Objects.ObjectContext.EnsureConnection()
   at System.Data.Objects.ObjectContext.SaveChanges(SaveOptions options)
   at System.Data.Objects.ObjectContext.SaveChanges()
   at Database_Test.Form1.saveButton_Click(Object sender, EventArgs e) in C:\Users\Jorge\Documents\Visual Studio 2010\Projects\Database_Test\Database_Test\Form1.cs:line 159

何度もオンラインで確認しましたが、正しい答えが得られないようです。何かご意見は?

4

2 に答える 2

0

MySql.Data.Entity.dllそれが機能するためにも含める必要があります

于 2013-10-18T07:54:47.997 に答える