Я получаю следующую ошибку при попытке протестировать страницу SWAGGER. Строка подключения была взята из обозревателя серверов в Visual Studio, поэтому я предполагаю, что все в порядке. Я могу получить доступ к серверу через SQL Server Management Studio или через проводник сервера в Visual Studio.
ОШИБКА
Microsoft.Data.SqlClient.SqlException ( 0x80131904): Недопустимое имя объекта «Рецепты».
Appsettings.json
"ConnectionStrings": {
"RecipeDatabaseConnection": "Data Source=IP_ADDRESS;Initial Catalog=DATABASE_NAME;Persist Security Info=True;User ID=USERNAME;Password=PASSWORD;Trust Server Certificate=True",
Context.cs
public class recipeDatabaseContext : DbContext
{
public recipeDatabaseContext(DbContextOptions options)
: base(options)
{
}
public DbSet Recipes { get; set; } = null!;
}
clRecipe.cs
[Key]
public int RecipeID { get; set; }
public string RecipeName { get; set; }
public string MealType { get; set; }
public string Rating { get; set; }
public bool SelectedToBeUsed { get; set; }
public int QuantityMultiplier { get; set; }
public int CookTime { get; set; }
public int PreparationTime { get; set; }
public string Instructions { get; set; }
public bool HiddenFlag { get; set; }
public int Stars { get; set; }
Контроллер
[HttpGet("{id}")]
public async Task GetclRecipe(int id)
{
var clRecipe = await _context.Recipes.FindAsync(id);
if (clRecipe == null)
{
return NotFound();
}
return clRecipe;
}
Подробнее здесь: https://stackoverflow.com/questions/793 ... sql-server
ASP.Net Core Web API — доступ к локально размещенному SQL-серверу ⇐ C#
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Подключение моей базы данных Google Cloud sql к моему размещенному php-приложению
Anonymous » » в форуме Php - 0 Ответы
- 79 Просмотры
-
Последнее сообщение Anonymous
-