using linq2db.MySqlConnector , but error like using "SqlServer"
See original GitHub issueI using linq2db.MySqlConnector
and develop follow this link https://linq2db.github.io/#now-lets-create-a-poco-class
but I got an error message not relate “MySql”, it’s look like “SqlServer”
This error message
Payload:
{
"errorType": "AggregateException",
"errorMessage": "One or more errors occurred. (The type initializer for 'LinqToDB.Data.DataConnection' threw an exception.)",
"stackTrace": [
"at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)",
"at lambda_method(Closure , Stream , Stream , LambdaContextInternal )"
],
"cause": {
"errorType": "TypeInitializationException",
"errorMessage": "The type initializer for 'LinqToDB.Data.DataConnection' threw an exception.",
"stackTrace": [
"at unit_detail.Services..ctor() in /Users/chitpong/Project/project/sourcecode_orm/project-api/project-api/src/unit_detail_noef/Services.cs:line 24",
"--- End of stack trace from previous location where exception was thrown ---",
"at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCreateInstance(CreateInstanceCallSite createInstanceCallSite, ServiceProviderEngineScope scope)",
"at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProviderEngineScope scope)",
"at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider provider)",
"at unit_detail.Function.FunctionHandler(APIGatewayProxyRequest request, ILambdaContext context) in /Users/chitpong/Project/project/sourcecode_orm/project-api/project-api/src/unit_detail_noef/Function.cs:line 68"
],
"cause": {
"errorType": "TypeInitializationException",
"errorMessage": "The type initializer for 'LinqToDB.DataProvider.SqlServer.SqlServerTools' threw an exception.",
"stackTrace": [
"at LinqToDB.DataProvider.SqlServer.SqlServerTools.GetDataProvider(SqlServerVersion version)",
"at LinqToDB.Data.DataConnection..cctor()"
],
"cause": {
"errorType": "FileNotFoundException",
"errorMessage": "Could not load file or assembly 'System.Data.SqlClient, Version=4.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.\n",
"stackTrace": [
"at LinqToDB.DataProvider.SqlServer.SqlServerDataProvider..ctor(String name, SqlServerVersion version)",
"at LinqToDB.DataProvider.SqlServer.SqlServerTools..cctor()"
]
}
}
},
"causes": [ {
"errorType": "TypeInitializationException",
"errorMessage": "The type initializer for 'LinqToDB.Data.DataConnection' threw an exception.",
"stackTrace": [
"at unit_detail.Services..ctor() in /Users/chitpong/Project/project/sourcecode_orm/project-api/project-api/src/unit_detail_noef/Services.cs:line 24",
"--- End of stack trace from previous location where exception was thrown ---",
"at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCreateInstance(CreateInstanceCallSite createInstanceCallSite, ServiceProviderEngineScope scope)",
"at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProviderEngineScope scope)",
"at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider provider)",
"at unit_detail.Function.FunctionHandler(APIGatewayProxyRequest request, ILambdaContext context) in /Users/chitpong/Project/project/sourcecode_orm/project-api/project-api/src/unit_detail_noef/Function.cs:line 68"
],
"cause": {
"errorType": "TypeInitializationException",
"errorMessage": "The type initializer for 'LinqToDB.DataProvider.SqlServer.SqlServerTools' threw an exception.",
"stackTrace": [
"at LinqToDB.DataProvider.SqlServer.SqlServerTools.GetDataProvider(SqlServerVersion version)",
"at LinqToDB.Data.DataConnection..cctor()"
],
"cause": {
"errorType": "FileNotFoundException",
"errorMessage": "Could not load file or assembly 'System.Data.SqlClient, Version=4.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.\n",
"stackTrace": [
"at LinqToDB.DataProvider.SqlServer.SqlServerDataProvider..ctor(String name, SqlServerVersion version)",
"at LinqToDB.DataProvider.SqlServer.SqlServerTools..cctor()"
]
}
}
}
]
}
Log Tail:
START RequestId: 033cc114-1706-4649-8ae3-6577ca646b54 Version: $LATEST
One or more errors occurred. (The type initializer for 'LinqToDB.Data.DataConnection' threw an exception.): AggregateException
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at lambda_method(Closure , Stream , Stream , LambdaContextInternal )
at unit_detail.Services..ctor() in /Users/chitpong/Project/project/sourcecode_orm/project-api/project-api/src/unit_detail_noef/Services.cs:line 24
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCreateInstance(CreateInstanceCallSite createInstanceCallSite, ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider provider)
at unit_detail.Function.FunctionHandler(APIGatewayProxyRequest request, ILambdaContext context) in /Users/chitpong/Project/project/sourcecode_orm/project-api/project-api/src/unit_detail_noef/Function.cs:line 68
The type initializer for 'LinqToDB.DataProvider.SqlServer.SqlServerTools' threw an exception.: TypeInitializationException
at LinqToDB.DataProvider.SqlServer.SqlServerTools.GetDataProvider(SqlServerVersion version)
at LinqToDB.Data.DataConnection..cctor()
Could not load file or assembly 'System.Data.SqlClient, Version=4.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.: FileNotFoundException
at LinqToDB.DataProvider.SqlServer.SqlServerDataProvider..ctor(String name, SqlServerVersion version)
at LinqToDB.DataProvider.SqlServer.SqlServerTools..cctor()
This my code
public class ConnectionStringSettings : IConnectionStringSettings
{
public string ConnectionString { get; set; }
public string Name { get; set; }
public string ProviderName { get; set; }
public bool IsGlobal => false;
}
public class MySettings : ILinqToDBSettings
{
public IEnumerable<IDataProviderSettings> DataProviders => Enumerable.Empty<IDataProviderSettings>();
public string DefaultConfiguration => "MyDatabase";
public string DefaultDataProvider => "MySqlConnector";
public IEnumerable<IConnectionStringSettings> ConnectionStrings
{
get
{
yield return
new ConnectionStringSettings
{
Name = "MyDatabase",
ProviderName = "MySqlConnector",
ConnectionString = "server=xxxx.com;userid=xxxxx;password=xxxxx;database=xxxxx;convert zero datetime=True; CharSet=utf8;"
};
}
}
}
.Net Core 2.1 linq2db.MySqlConnector 2.7.0
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Error connecting to database using Linq
This is my appconfig.xml in project with linq2db. ... Add your connection string to MySql after this line--> </connectionStrings>.
Read more >Character Set 'utf8mb3' is not supported by .Net Framework
I use Net Framework 4.5.2, MySQL Connector Net 8.0.29, MySQL for Visual Studio 1.2.8 (I try to load tables to Visual Studio 2013)....
Read more >4.1 Creating a Connector/NET Connection String
The MySqlConnection object is configured using a connection string. A connection string contains several key-value pairs, separated by semicolons.
Read more >LINQ to DB | Linq To DB
LINQ to DB is the fastest LINQ database access library offering a simple, light, fast, and type-safe layer between your POCO objects and...
Read more >5.2 Using MySqlCommand
The MySqlCommand class represents a SQL statement to execute against a MySQL database. ... the attempt is logged by the connector but no...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
fixed by #1929
I’m reopening it, as a fix for #1704 will be just a quick fix to dependency versions. We will use this issue to track removal of explicit system.data.sqlclient dependency