Quick note on a solution to what could have been a game-breaking problem. Was building out Microsoft's tutorial app for .NET Core with the EF Framework and got to the section on seeding the database. To set up your connection string, you get the following line of code:
(In Startup.cs)
When I ran my build, in conjunction with the other seeding stuff the tutorial gives you, I got all sorts of errors. For example, I would set up my connection string as follows:
server=localhost;user=root;password=root;database=mydb;port=3306
And get an error: "Keyword is not supported: port."
I panicked. Microsoft's system for building out the database wasn't going to work, and I was going to have to figure out a workaround using EF migrations. But after some searching, I found this.
The problem is the line UseSqlServer (and copying blindly). Because I'm not using SqlServer, I'm using MySql. So just change that to UseMySql and everything runs smoothly. Whew!
(In Startup.cs)
public void ConfigureServices(IServiceCollection services) { services.AddDbContext<SchoolContext>( options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")) ); services.AddMvc(); }
server=localhost;user=root;password=root;database=mydb;port=3306
And get an error: "Keyword is not supported: port."
I panicked. Microsoft's system for building out the database wasn't going to work, and I was going to have to figure out a workaround using EF migrations. But after some searching, I found this.
The problem is the line UseSqlServer (and copying blindly). Because I'm not using SqlServer, I'm using MySql. So just change that to UseMySql and everything runs smoothly. Whew!
Comments
Post a Comment