I am trying to build an asp.net core mvc application. I have an already existing remote database on this website that provides free sql server https://www.freesqldatabase.com/
when I created the database I have recieved an email with credentials of the db Host: sql6.freesqldatabase.com Database name: sql6455969 Database user: sql6455969 Database password: pass Port number: 3306
Now I am trying to connect to it but it gives me this error An unhandled exception occurred while processing the request. InvalidOperationException: Internal connection fatal error.
This is the code in appsettings.json file
"ConnectionStrings": {
"APDBConnection": "Server = sql6.freesqldatabase.com,3306; Database = sql6455969; User Id = sql6455969; Password = pass;"
},
code in startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(
Configuration.GetConnectionString("APDBConnection")
)
);
services.AddControllersWithViews();
}
I don't know what is the problem with the connection
Thanks to Ian's answer I have found that I should use UseMySql instead of UseSqlServer and install Pomelo.EntityFrameworkCore.MySql packet
services.AddDbContext<ApplicationDbContext>(options =>
options.UseMySql(
Configuration.GetConnectionString("APDBConnection")
)
);
CodePudding user response:
It would be really great if you'd read the actual website:
Currently we offer MySQL with plans to launch further database platforms with multiple platforms including the latest releases.
MySQL is not MSSQL.