我正在尝试使用.NET 6 Web &实体框架核心()来制作CRUD,并且在进行迁移更新时遇到了问题。MS SQL用作数据库。
给我的数据库的名称是用非英语命名的,比如'ZİRVEDB‘。我不知道他们为什么这么做,但他们把数据库命名成这样。
ConnectionStrings文件中的“appsettings.json”如下所示:
{
"ConnectionStrings": {
"DefaultConnection" : "Server=myServerAddress;Database=ZİRVEDB;User Id=myUsername;Password=myPassword;"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}Program.cs文件包含:
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();当我尝试"dotnet ef database update“时,由于非英语字符,它创建了一个像Z�RVEDB这样的新数据库,并将迁移保存在那里。但是我已经有了一个现有的数据库,我希望它保存在那个数据库中。
以下是我尝试过的:
在数据库设置中将其
"...;Database=\"ZİRVEDB\"""..;Database='ZİRVEDB'"Turkish_CI_AI“.但这些都不起作用。我该如何解决这个问题?
谢谢。
发布于 2022-08-25 21:00:30
启动cs
System.Text.Encodings.Web.TextEncoderSettings(UnicodeRanges.All);(o => { o.TextEncoderSettings =新的o.TextEncoderSettings });
布努·亚帕尔
https://stackoverflow.com/questions/71628353
复制相似问题