Entity Framework 5 IBM DB2 EntityException The underlying provider failed on ConnectionString - entity-framework

I am using Visual Studio 2012 to build a web application. The application uses webforms, Entity Framework 5 with an IBM DB2 database server. I have the latest IBM Drivers v10.1.2 installed on both my development machine and my web server. The web server is running Windows Server 2008 R2 Standard x64bit OS.
Problem Im having is running the app under Visual Studio's IIS Express on my local machine works fine, however when I deployed the app the web server I am getting problems EF and DB2 Drivers. Here is the error and stack trace. What am doing wrong?!
Server Error in '/' Application.
--------------------------------------------------------------------------------
ERROR [] [IBM][CLI Driver] SQL0000W Statement processing was successful.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: IBM.Data.DB2.DB2Exception: ERROR [] [IBM][CLI Driver] SQL0000W Statement processing was successful.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[DB2Exception (0x80004005): ERROR [] [IBM][CLI Driver] SQL0000W Statement processing was successful.]
IBM.Data.DB2.ConnSettingsFromXmlConfig.ProcessFromXmlConfig(DB2Connection connection, String dbname, String host, String port, String tmpClientEncAlg, String tmpAuthentication, String prevdb, String prevdb_ori, DB2ConnSettings& sSettings, DB2ConnSettingsInternal& sSettingsInternal, StringBuilder& modifiedValue) +21370
IBM.Data.DB2.DB2ConnPool.ReplaceConnectionStringParms(DB2Connection connection, String szValue, DB2ConnSettings& pSettings, DB2ConnSettingsInternal& pSettingsInternal, Boolean bAttach, Boolean pushDownStrAppended) +19113
IBM.Data.DB2.DB2Connection.set_ConnectionString(String value) +187
System.Data.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString) +325
[EntityException: The underlying provider failed on ConnectionString.]
System.Data.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString) +391
System.Data.EntityClient.EntityConnection..ctor(String connectionString) +43
System.Data.Entity.Internal.LazyInternalConnection.InitializeFromConnectionStringSetting(ConnectionStringSettings appConfigConnection) +78
System.Data.Entity.Internal.LazyInternalConnection.TryInitializeFromAppConfig(String name, AppConfig config) +32
System.Data.Entity.Internal.LazyInternalConnection.Initialize() +127
System.Data.Entity.Internal.LazyInternalConnection.CreateObjectContextFromConnectionModel() +13
System.Data.Entity.Internal.LazyInternalContext.InitializeContext() +281
System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) +18
System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() +52
System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext() +15
System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider() +37
System.Linq.Queryable.Where(IQueryable`1 source, Expression`1 predicate) +63
....

I had the same problem and changing the app pool to Network Service did the trick.

Related

Database Migration is getting failed due to NLOG.config in Visual Studio 2022 Mac

I started programming with Visual Studio 2022 in Mac M1. I am developing an application with .net core 6 and initially I used to develop in Windows. I copied my project and started to work in VS 2022 Mac. While doing the DB Migration (Using dotnet CLI) I am getting error and it's getting failed due to NLog.config. I am using NLog for the logging functionality.
DataAccess layer and WepAPI are separate project in a solution.DBContextClass and migration scripts are present in DataAccess Layer and the connection string is present in WebAPI.
Error while doing the db migration:
Time Elapsed 00:00:01.65 Build succeeded. dotnet exec --depsfile
/Users/MASKED/Projects/MyCoreApplication/MyCoreApplicationWebAPI/bin/Debug/net6.0/MyCoreApplicationWebAPI.deps.json
--additionalprobingpath /Users/MASKED/.nuget/packages --runtimeconfig /Users/MASKED/Projects/MyCoreApplication/MyCoreApplicationWebAPI/bin/Debug/net6.0/MyCoreApplicationWebAPI.runtimeconfig.json
/Users/MASKED/.dotnet/tools/.store/dotnet-ef/6.0.7/dotnet-ef/6.0.7/tools/net6.0/any/tools/netcoreapp2.0/any/ef.dll
database update -c ApplicationDbContext --assembly
/Users/MASKED/Projects/MyCoreApplication/MyCoreApplicationWebAPI/bin/Debug/net6.0/MyCoreApplication.DataAccess.dll
--project /Users/MASKED/Projects/MyCoreApplication/MyCoreApplication.DataAccess/MyCoreApplication.DataAccess.csproj
--startup-assembly /Users/MASKED/Projects/MyCoreApplication/MyCoreApplicationWebAPI/bin/Debug/net6.0/MyCoreApplicationWebAPI.dll
--startup-project /Users/MASKED/Projects/MyCoreApplication/MyCoreApplicationWebAPI/MyCoreApplicationWebAPI.csproj
--project-dir /Users/MASKED/Projects/MyCoreApplication/MyCoreApplication.DataAccess/
--root-namespace MyCoreApplication.DataAccess --language C# --framework net6.0 --nullable --working-dir /Users/MASKED/Projects/MyCoreApplication/MyCoreApplication.DataAccess
--verbose Using assembly 'MyCoreApplication.DataAccess'. Using startup assembly 'MyCoreApplicationWebAPI'. Using application base
'/Users/MASKED/Projects/MyCoreApplication/MyCoreApplicationWebAPI/bin/Debug/net6.0'.
Using working directory
'/Users/MASKED/Projects/MyCoreApplication/MyCoreApplicationWebAPI'.
Using root namespace 'MyCoreApplication.DataAccess'. Using project
directory
'/Users/MASKED/Projects/MyCoreApplication/MyCoreApplication.DataAccess/'.
Remaining arguments: . Finding DbContext classes... Finding
IDesignTimeDbContextFactory implementations... Finding application
service provider in assembly 'MyCoreApplicationWebAPI'... Finding
Microsoft.Extensions.Hosting service provider... Using environment
'Development'. NLog.NLogConfigurationException: Exception when loading
configuration
/Users/MASKED/Projects/MyCoreApplication/MyCoreApplicationWebAPI/nlog.config
---> System.Xml.XmlException: Root element is missing. at System.Xml.XmlTextReaderImpl.Throw(Exception e) at
System.Xml.XmlTextReaderImpl.ParseDocumentContent() at
System.Xml.XmlTextReaderImpl.Read() at
System.Xml.XmlReader.MoveToContent() at
NLog.Config.XmlLoggingConfiguration.Initialize(XmlReader reader,
String fileName, Boolean ignoreErrors) --- End of inner exception
stack trace --- at
NLog.Config.XmlLoggingConfiguration.Initialize(XmlReader reader,
String fileName, Boolean ignoreErrors) at
NLog.Config.XmlLoggingConfiguration..ctor(XmlReader reader, String
fileName, LogFactory logFactory) at
NLog.Config.LoggingConfigurationFileLoader.LoadXmlLoggingConfiguration(XmlReader
xmlReader, String configFile, LogFactory logFactory) at
NLog.Config.LoggingConfigurationFileLoader.LoadXmlLoggingConfigurationFile(LogFactory
logFactory, String configFile) at
NLog.Config.LoggingConfigurationFileLoader.TryLoadLoggingConfiguration(LogFactory
logFactory, String configFile, LoggingConfiguration& config) at
NLog.Config.LoggingConfigurationFileLoader.Load(LogFactory logFactory,
String filename) at
NLog.Config.LoggingConfigurationWatchableFileLoader.Load(LogFactory
logFactory, String filename) at
NLog.LogFactory.LoadConfiguration(String configFile, Boolean optional)
at NLog.LogFactory.LoadConfiguration(String configFile) at
NLog.LogManager.LoadConfiguration(String configFile) at
Program.$(String[] args) in
/Users/MASKED/Projects/MyCoreApplication/MyCoreApplicationWebAPI/Program.cs:line
25
--- End of stack trace from previous location --- at Microsoft.Extensions.Hosting.HostFactoryResolver.HostingListener.CreateHost()
at
Microsoft.Extensions.Hosting.HostFactoryResolver.<>c__DisplayClass10_0.b__0(String[]
args) at
Microsoft.Extensions.Hosting.HostFactoryResolver.<>c__DisplayClass13_0.b__3(String[]
args) at
Microsoft.EntityFrameworkCore.Design.Internal.AppServiceProviderFactory.CreateFromHosting(String[]
args)
An error occurred while accessing the Microsoft.Extensions.Hosting services. Continuing without the application service provider. Error:
Exception when loading configuration
/Users/MASKED/Projects/MyCoreApplication/MyCoreApplicationWebAPI/nlog.config
No application service provider was found. Finding DbContext classes
in the project... Found DbContext 'ApplicationDbContext'.
Microsoft.EntityFrameworkCore.Design.OperationException: Unable to
create an object of type 'ApplicationDbContext'. For the different
patterns supported at design time, see
https://go.microsoft.com/fwlink/?linkid=851728 --->
System.InvalidOperationException: Unable to resolve service for type
'Microsoft.EntityFrameworkCore.DbContextOptions1[MyCoreApplication.DataAccess.Data.ApplicationDbContext]' while attempting to activate 'MyCoreApplication.DataAccess.Data.ApplicationDbContext'. at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.ConstructorMatcher.CreateInstance(IServiceProvider provider) at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.CreateInstance(IServiceProvider provider, Type instanceType, Object[] parameters) at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.GetServiceOrCreateInstance(IServiceProvider provider, Type type) at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.<>c__DisplayClass21_4.<FindContextTypes>b__13() --- End of inner exception stack trace --- at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.<>c__DisplayClass21_4.<FindContextTypes>b__13() at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.CreateContext(Func1
factory) at
Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.CreateContext(String
contextType) at
Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.UpdateDatabase(String
targetMigration, String connectionString, String contextType) at
Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabaseImpl(String
targetMigration, String connectionString, String contextType) at
Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabase.<>c__DisplayClass0_0.<.ctor>b__0()
at
Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action
action)
Unable to create an object of type 'ApplicationDbContext'. For the different patterns supported at design time, see
https://go.microsoft.com/fwlink/?linkid=851728

Unable to connect to Azure Cosmos Db Account (Core SQL API) using EF Core 3.0 CosmosDb provider

I'm unable to connect to an Azure CosmosDB with the CosmosDb provider using the following packages:
Microsoft.EntityFrameworkCore 3.0.0
Microsoft.EntityFrameworkCore.Cosmos 3.0.0
Getting this message back:
Response status code does not indicate success: 503 Substatus: 0 Reason: (The request failed because the client was unable to establish connections to 3 endpoints across 1 regions. Please check for client resource starvation issues and verify connectivity between client and server.
Stacktrace
at Microsoft.Azure.Cosmos.ResponseMessage.EnsureSuccessStatusCode() at Microsoft.Azure.Cosmos.CosmosResponseFactory.ToObjectInternal[T](ResponseMessage cosmosResponseMessage, CosmosSerializer jsonSerializer)
at Microsoft.Azure.Cosmos.CosmosResponseFactory.<>c__DisplayClass6_0.<CreateDatabaseResponseAsync>b__0(ResponseMessage cosmosResponseMessage)
at Microsoft.Azure.Cosmos.CosmosResponseFactory.<ProcessMessageAsync>d__121.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at Microsoft.Azure.Cosmos.CosmosClient.<CreateDatabaseIfNotExistsAsync>d__40.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult()
at Microsoft.EntityFrameworkCore.Cosmos.Storage.Internal.CosmosClientWrapper.d__13.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at Microsoft.EntityFrameworkCore.Cosmos.Storage.Internal.CosmosClientWrapper.CreateDatabaseIfNotExistsOnce(DbContext context, Object state)
at Microsoft.EntityFrameworkCore.Storage.ExecutionStrategy.ExecuteImplementation[TState,TResult](Func3 operation, Func3 verifySucceeded, TState state)
at Microsoft.EntityFrameworkCore.Storage.ExecutionStrategy.Execute[TState,TResult](TState state, Func3 operation, Func3 verifySucceeded)
at Microsoft.EntityFrameworkCore.Cosmos.Storage.Internal.CosmosClientWrapper.CreateDatabaseIfNotExists() at Microsoft.EntityFrameworkCore.Cosmos.Storage.Internal.CosmosDatabaseCreator.EnsureCreated()
at Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade.EnsureCreated() at EFCoreCosmosDbTest.Test.<Run>d__0.MoveNext() in C:\Git\EFCoreCosmosDbTest\EFCoreCosmosDbTest\Test.cs:line 26
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at EFCoreCosmosDbTest.Program.<Main>d__0.MoveNext()
in C:\Git\EFCoreCosmosDbTest\EFCoreCosmosDbTest\Program.cs:line 9
If I change to the Microsoft.Azure.DocumentDB.Core 2.8.1 and use the DocumentClient I have no issues connecting to the same CosmosDb account in Azure and create my database, container etc. from the same solution.
Also, if I download the .net core quickstart project from Azure, it works without issues.
Note, that It works fine connecting to a the Azure Cosmos Db Emulator locally with EF.
I used the https://github.com/aspnet/EntityFramework.Docs/tree/master/samples/core/Cosmos repo to run the test.
Any ideas what I'm doing wrong?
EF Core version: 3.0
Database provider: Microsoft.EntityFrameworkCore.CosmosDb
Target framework: .NET Core 3.0
The EF Provider is using the Cosmos SDK package underneath.
Please add the Microsoft.Azure.Cosmos package to your project targeting the latest version (3.2.2).
You can do this through the NET Core CLI by running dotnet add package Microsoft.Azure.Cosmos on the folder with your current project files, and it should update your CSPROJ with the PackageReference.

spring-boot configure hibernate-ogm for MongoDB

APPLICATION FAILED TO START
Description:
Cannot determine embedded database driver class for database type NONE
Action:
If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (the profiles "local" are currently active).
2016-11-10 18:36:52.335 ERROR 1288 --- [ main] o.s.test.context.TestContextManager : Caught exception while allowing TestExecutionListener [org.springframework.test.context.web.ServletTestExecutionListener#d83da2e] to prepare test instance [com.example.DemoApplicationTests#1f68e4e8]
java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124) ~[spring-test-4.3.4.RELEASE.jar:4.3.4.RELEASE]
at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:83) ~[spring-test-4.3.4.RELEASE.jar:4.3.4.RELEASE]

Hosting internal Nuget and Symbols server

I have setup the Nuget.Server and the SymbolSource Server Basic in one solution when I run the "self diagnostics tool" I get the following exception, anyone have a clue what this is?
The URL I am accessing is
http://localhost/Home/NuGetPushTest
Method not found: 'Void NuGet.PackageServer.PushPackage(System.String,
System.IO.Stream, Int32)'.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.MissingMethodException: Method not found:
'Void NuGet.PackageServer.PushPackage(System.String, System.IO.Stream,
Int32)'.
Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.

SOAP Security negotiation Error while calling Microsoft Dynamics CRM 2011 sdk IOrganizationServiceProxy web service

we have a virtual machine in our company that contains sqlserver and crm 2011 installed on It which we use It for testing our codes and I have written a simple webservice to call the sdk IOrganizationServieProxy webservice . on this Virtual machine my code works perfeclty with no error . BUT here is the situation : we have two other virtual machines , on one of them the sql server is installed and on the other one crm is installed and configured . the crm works fine but when I try to use my web service which calls the crm sdk IOrganizationServieProxy webservice webmethods I get the following errorr , any Ideas what could be wrong ? thanks in advance for anyone who answears this question .
System.ServiceModel.Security.SecurityNegotiationException: SOAP security negotiation with 'http://localhost/KN/XRMServices/2011/Organization.svc' for target 'http://localhost/KN/XRMServices/2011/Organization.svc' failed. See inner exception for more details. ---> System.ComponentModel.Win32Exception: The Security Support Provider Interface (SSPI) negotiation failed.
at System.ServiceModel.Security.WindowsSspiNegotiation.GetOutgoingBlob(Byte[] incomingBlob, ChannelBinding channelbinding, ExtendedProtectionPolicy protectionPolicy)
at System.ServiceModel.Security.SspiNegotiationTokenProvider.GetNextOutgoingMessageBody(Message incomingMessage, SspiNegotiationTokenProviderState sspiState)
at System.ServiceModel.Security.IssuanceTokenProviderBase`1.GetNextOutgoingMessage(Message incomingMessage, T negotiationState)
at System.ServiceModel.Security.IssuanceTokenProviderBase`1.DoNegotiation(TimeSpan timeout)
--- End of inner exception stack trace ---
Server stack trace:
at System.ServiceModel.Security.IssuanceTokenProviderBase`1.DoNegotiation(TimeSpan timeout)
at System.ServiceModel.Security.SspiNegotiationTokenProvider.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Security.SymmetricSecurityProtocol.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Channels.SecurityChannelFactory`1.ClientSecurityChannel`1.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(TimeSpan timeout, CallOnceManager cascade)
at System.ServiceModel.Channels.ServiceChannel.EnsureOpened(TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at Microsoft.Xrm.Sdk.IOrganizationService.RetrieveMultiple(QueryBase query)
at Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.RetrieveMultipleCore(QueryBase query)
at KNCRMSearchWebService.searchContactsByNameAndFamilyName(String cl, String Name, String Family)
and here is an image from my visualstudio debug mode which shows the error :
It may not apply, but I have run into problems when the URL I used didn't match the WCF bindings set in the CRM Deployment Manager.
For instance, a server named "MyCRMServer" might be listening on port 80 at:
http://MyCrmServer/
...but if I had changed my CRM Server in Deployment Manager to url "crm.myCompany.com" then I have to use this URL to access web services:
http://crm.myCompany.com/