I am trying to make a CRUD with a .NET 6 Web API & Entity Framework Core and I'm having a problem doing a migration update. MS SQL is used as database.
The name of the database given to me is made with a non-English naming like 'ZİRVEDB'. I don't know why they did such a thing, but they named the database like this.
The "ConnectionStrings" in the appsettings.json file looks like this:
{
"ConnectionStrings": {
"DefaultConnection" : "Server=myServerAddress;Database=ZİRVEDB;User Id=myUsername;Password=myPassword;"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
Program.cs file contains:
global using MyAPI.Data;
global using Microsoft.EntityFrameworkCore;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
builder.Services.AddDbContext<DataContext>(options =>
{
options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection"));
});
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();
And when I try to "dotnet ef database update", due to non-English character, it creates a new database like Z�RVEDB and saves the migration there. But I already have an existing database and I want it to save in that database.
Here's what I've tried:
"...;Database=\"ZİRVEDB\"""..;Database='ZİRVEDB'"- Set it to "
Turkish_CI_AI" in database settings.
But these did not work. How can i solve this problem?
Thanks.
Startup cs
services.AddWebEncoders(o => { o.TextEncoderSettings = new System.Text.Encodings.Web.TextEncoderSettings(UnicodeRanges.All); });
bunu yaparsan düzelir