TryCatchLearn / DatingApp

266 stars 137 forks source link

I have a problem #5

Open IbrahimNaserALdeen opened 7 months ago

IbrahimNaserALdeen commented 7 months ago

using API.Data;

using Microsoft.EntityFrameworkCore;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.

builder.Services.AddControllers(); builder.Services.AddDbContext(opt=> { opt.UseSqlite(builder.Configuration.GetConnectionString("DefaultConnection")); });

var app = builder.Build();

app.UseHttpsRedirection();

app.UseAuthorization();

app.MapControllers();

app.Run();


{ "Logging": { "LogLevel": { "Default": "Information", "Microsoft.AspNetCore": "Warning" }, "ConnectionStrings": { "DefaultConnection": "Data Source=datingapp.db" } } }

using API.Entities; using Microsoft.EntityFrameworkCore;

namespace API.Data;

public class DataContext : DbContext { public DataContext(DbContextOptions options) : base(options) {

}

public DbSet Users { get; set; }
}

Build started... Build succeeded. info: Microsoft.EntityFrameworkCore.Database.Command[20101] Executed DbCommand (14ms) [Parameters=[], CommandType='Text', CommandTimeout='30'] SELECT COUNT() FROM "sqlite_master" WHERE "name" = 'EFMigrationsHistory' AND "type" = 'table'; info: Microsoft.EntityFrameworkCore.Database.Command[20101] Executed DbCommand (1ms) [Parameters=[], CommandType='Text', CommandTimeout='30'] CREATE TABLE "EFMigrationsHistory" ( "MigrationId" TEXT NOT NULL CONSTRAINT "PK___EFMigrationsHistory" PRIMARY KEY, "ProductVersion" TEXT NOT NULL ); info: Microsoft.EntityFrameworkCore.Database.Command[20101] Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30'] SELECT COUNT() FROM "sqlite_master" WHERE "name" = 'EFMigrationsHistory' AND "type" = 'table'; info: Microsoft.EntityFrameworkCore.Migrations[20402] Applying migration '20240219150026_InitialCreate'. Applying migration '20240219150026_InitialCreate'. info: Microsoft.EntityFrameworkCore.Database.Command[20101] Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30'] CREATE TABLE "Users" ( "Id" INTEGER NOT NULL CONSTRAINT "PK_Users" PRIMARY KEY AUTOINCREMENT, "UserName" TEXT NULL fail: Microsoft.EntityFrameworkCore.Database.Command[20102] Failed executing DbCommand (2ms) [Parameters=[], CommandType='Text', CommandTimeout='30'] INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion") VALUES ('20240219150026_InitialCreate', '8.0.2'); Failed executing DbCommand (2ms) [Parameters=[], CommandType='Text', CommandTimeout='30'] INSERT INTO "EFMigrationsHistory" ("MigrationId", "ProductVersion") VALUES ('20240219150026_InitialCreate', '8.0.2'); Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 1: 'no such table: EFMigrationsHistory'. at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db) at Microsoft.Data.Sqlite.SqliteCommand.PrepareAndEnumerateStatements()+MoveNext() at Microsoft.Data.Sqlite.SqliteCommand.GetStatements()+MoveNext() at Microsoft.Data.Sqlite.SqliteDataReader.NextResult() at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior) at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader() at Microsoft.Data.Sqlite.SqliteCommand.ExecuteNonQuery() at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteNonQuery(RelationalCommandParameterObject parameterObject) at Microsoft.EntityFrameworkCore.Migrations.MigrationCommand.ExecuteNonQuery(IRelationalConnection connection, IReadOnlyDictionary2 parameterValues) at Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationCommandExecutor.ExecuteNonQuery(IEnumerable1 migrationCommands, IRelationalConnection connection) at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration) at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.UpdateDatabase(String targetMigration, String connectionString, String contextType) at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabaseImpl(String targetMigration, String connectionString, String contextType) at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabase.<>cDisplayClass0_0.<.ctor>b0() at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action) SQLite Error 1: 'no such table: EFMigrationsHistory'. PS C:\Users\ibrahim\DatingApp\API> dotnet ef database update

plogramer commented 7 months ago

What's your problem?

IbrahimNaserALdeen commented 7 months ago

‫في الأحد، 25 فبراير 2024 في 11:22 ص تمت كتابة ما يلي بواسطة ‪Kenny Kim‬‏ <‪ @.***‬‏>:‬

What's your problem?

— Reply to this email directly, view it on GitHub https://github.com/TryCatchLearn/DatingApp/issues/5#issuecomment-1962854156, or unsubscribe https://github.com/notifications/unsubscribe-auth/BF7BVHW5VUNHR7LDRVC3YUTYVLYDFAVCNFSM6AAAAABDQ4QUC2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRSHA2TIMJVGY . You are receiving this because you authored the thread.Message ID: @.***>