I've been working to set up Entity Framework using VS code, using this tutorial:
https://www.learnentityframeworkcore.com/walkthroughs/aspnetcore-application
however, when executing the migration- I encountered this specific error: Keyword not supported: 'port'
The best reference I've found thus far to help out is this stackoverflow, however, due to the setup I've been following thus far, none of the solutions seem to work
C# Entity Framework: Keyword not supported: 'port'
This is the code that seems to be causing me trouble:
using Microsoft.EntityFrameworkCore;
namespace EFPrac
{
public class EFCoreWebDemoContext : DbContext
{
public DbSet<Book> Books { get; set; }
public DbSet<Author> Authors { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
string connectionString = "server=localhost;port=3306;database=EFpractice;uid=root,Pwd=****";
optionsBuilder.UseSqlServer(connectionString);
}
}
}
connectionstrings.com is a great site for connection string question
Using a non-standard port
If your SQL Server listens on a non-default port you can specify that using the servername,xxxx syntax (note the comma, it's not a colon).
Server=myServerName,myPortNumber;Database=myDataBase;User Id=myUsername;Password=myPassword;
Also, try this way:
string connectionString="server=localhost,3306;database=EFpractice;uid=root,Pwd=****"
That's actually the site I used to create my connection string! I attempted your fix and a similar error continued: this time throwing: Internal connection fatal error.
Edit: tried the non-default port solution and A connection was successfully established with the server, thanks for your help! I at least have a foothold to start debugging the new errors now!