I am completely new to Entity Framework and even ADO.NET in general (don't typically do much work with databases).
(things
is just a bogus table I threw together with some arbitrary fields.)
TestDataEntities entities = new TestDataEntities();
var things = entities.things.Execute(MergeOption.AppendOnly); // exception
The above threw a NullReferenceException
and I'm really clueless as to why that could be. When I test the connection, it says it succeeded. I have definitely set up the connection with the correct user name and password. I don't even know what else to investigate.
For those of you who actually know about this stuff, here's the exception I got (though, to my untrained eyes, this doesn't actually look like it would be all that helpful):
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(Action`3 addError) at System.Data.Metadata.Edm.StoreItemCollection.Loader.OnProviderManifestTokenNotification(String token, Action`3 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(IEnumerable`1 xmlReaders, IEnumerable`1 sourceFilePaths, SchemaDataModelOption dataModel, AttributeValueNotification providerNotification, AttributeValueNotification providerManifestTokenNotification, ProviderManifestNeeded providerManifestNeeded, IList`1& schemaCollection) at System.Data.Metadata.Edm.StoreItemCollection.Loader.LoadItems(IEnumerable`1 xmlReaders, IEnumerable`1 sourceFilePaths) at System.Data.Metadata.Edm.StoreItemCollection.Init(IEnumerable`1 xmlReaders, IEnumerable`1 filePaths, Boolean throwOnError, DbProviderManifest& providerManifest, DbProviderFactory& providerFactory, Memoizer`2& cachedCTypeFunction) at System.Data.Metadata.Edm.StoreItemCollection..ctor(IEnumerable`1 xmlReaders, IEnumerable`1 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](IItemCollectionLoader`1 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.ObjectQuery`1.GetResults(Nullable`1 forMergeOption) at System.Data.Objects.ObjectQuery`1.Execute(MergeOption mergeOption) at EntityFrameworkTest.Form1..ctor() in D:\Development\EntityFrameworkTest\Form1.cs:line 23 at EntityFrameworkTest.Program.Main() in D:\Development\EntityFrameworkTest\Program.cs:line 18 at System.AppDomain._nExecuteAssembly(Assembly 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.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()
I got past this error by adding a reference to MySql.Data.Entity.dll (and MySql.Web.dll)