Tiltyboi
Tiltyboi
CC#
Created by Tiltyboi on 8/10/2024 in #help
✅ Cannot connect to mysql docker container db from AspNet Core App
Ah that worked! Thanks so much! @beware of the leopard :prayge: Have a good day/evening
19 replies
CC#
Created by Tiltyboi on 8/10/2024 in #help
✅ Cannot connect to mysql docker container db from AspNet Core App
but my image is mysql:latest
19 replies
CC#
Created by Tiltyboi on 8/10/2024 in #help
✅ Cannot connect to mysql docker container db from AspNet Core App
Well i want to use mysql becuase i have experience in it
19 replies
CC#
Created by Tiltyboi on 8/10/2024 in #help
✅ Cannot connect to mysql docker container db from AspNet Core App
Sorry i dont know .NET very well
19 replies
CC#
Created by Tiltyboi on 8/10/2024 in #help
✅ Cannot connect to mysql docker container db from AspNet Core App
Is that not the same `?
19 replies
CC#
Created by Tiltyboi on 8/10/2024 in #help
✅ Cannot connect to mysql docker container db from AspNet Core App
i tried creating a standalone app with the same connection string and connecting, it worked after creating the database manually in the docker container. But then trying from Update Database doesnt work and gives this error:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
@beware of the leopard
19 replies
CC#
Created by Tiltyboi on 8/10/2024 in #help
✅ Cannot connect to mysql docker container db from AspNet Core App
No my app is runnig on host machine while my mysql server is running on a docker container on my host.
19 replies
CC#
Created by Tiltyboi on 8/10/2024 in #help
EF-Core migrations issue
On further investigation might have been a db connection string issue. Re-running the command after testing the connStr gives me a new error:
Your target project 'SadBot.Core' doesn't match your migrations assembly 'SadBot.Migrations'. Either change your target project or change your migrations assembly.
Change your migrations assembly by using DbContextOptionsBuilder. E.g. options.UseSqlServer(connection, b => b.MigrationsAssembly("SadBot.Core")). By default, the migrations assembly is the assembly containing the DbContext.
Change your target project to the migrations project by using the Package Manager Console's Default project drop-down list, or by executing "dotnet ef" from the directory containing the migrations project
Your target project 'SadBot.Core' doesn't match your migrations assembly 'SadBot.Migrations'. Either change your target project or change your migrations assembly.
Change your migrations assembly by using DbContextOptionsBuilder. E.g. options.UseSqlServer(connection, b => b.MigrationsAssembly("SadBot.Core")). By default, the migrations assembly is the assembly containing the DbContext.
Change your target project to the migrations project by using the Package Manager Console's Default project drop-down list, or by executing "dotnet ef" from the directory containing the migrations project
2 replies
CC#
Created by Tiltyboi on 8/5/2024 in #help
dotnet-ef error creating migrations
Program.cs
namespace SadMemerBot
{
public class Program
{
private DiscordSocketClient _client;

private Program()
{
_client = new DiscordSocketClient(); // commented out for abbrevity
}

public static Task Main(string[] args) => new Program().MainAsync(args);

public async Task MainAsync(string[] args)
{
var host = Host.CreateApplicationBuilder(args);


//Add any other services here
// services .....
var sqlDbConn = host.Configuration.GetConnectionString("SqlConnection");
host.Services.AddDbContext<RPGContext>(options =>
{
options.UseSqlServer(sqlDbConn, x => x.MigrationsAssembly("SadBot.Migrations"));
});

var runner = host.Build();
await runner.RunAsync();
}
namespace SadMemerBot
{
public class Program
{
private DiscordSocketClient _client;

private Program()
{
_client = new DiscordSocketClient(); // commented out for abbrevity
}

public static Task Main(string[] args) => new Program().MainAsync(args);

public async Task MainAsync(string[] args)
{
var host = Host.CreateApplicationBuilder(args);


//Add any other services here
// services .....
var sqlDbConn = host.Configuration.GetConnectionString("SqlConnection");
host.Services.AddDbContext<RPGContext>(options =>
{
options.UseSqlServer(sqlDbConn, x => x.MigrationsAssembly("SadBot.Migrations"));
});

var runner = host.Build();
await runner.RunAsync();
}
And then RPGContext:
using Microsoft.EntityFrameworkCore;
using SadBot.Core.Database.Models.Items;

namespace SadBot.Core.Database
{
public class RPGContext : DbContext
{
public RPGContext(DbContextOptions<RPGContext> options) : base(options) { }
public DbSet<Item> Items { get; set; }
}
}
using Microsoft.EntityFrameworkCore;
using SadBot.Core.Database.Models.Items;

namespace SadBot.Core.Database
{
public class RPGContext : DbContext
{
public RPGContext(DbContextOptions<RPGContext> options) : base(options) { }
public DbSet<Item> Items { get; set; }
}
}
3 replies
CC#
Created by Tiltyboi on 11/27/2023 in #help
C# IConfiguration not loading appsettings
Host still doesnt allow anything but DefaultBuilder, but it boots now anyway.. I will consider refactoring the service instead of using IConfiguration values.. Thanks ThumbsUp
178 replies
CC#
Created by Tiltyboi on 11/27/2023 in #help
C# IConfiguration not loading appsettings
i did that and now it boots!
178 replies
CC#
Created by Tiltyboi on 11/27/2023 in #help
C# IConfiguration not loading appsettings
u said earlier to swap in csproj
178 replies
CC#
Created by Tiltyboi on 11/27/2023 in #help
C# IConfiguration not loading appsettings
i realized
178 replies
CC#
Created by Tiltyboi on 11/27/2023 in #help
C# IConfiguration not loading appsettings
ong
178 replies
CC#
Created by Tiltyboi on 11/27/2023 in #help
C# IConfiguration not loading appsettings
wait
178 replies
CC#
Created by Tiltyboi on 11/27/2023 in #help
C# IConfiguration not loading appsettings
to 8.0
178 replies
CC#
Created by Tiltyboi on 11/27/2023 in #help
C# IConfiguration not loading appsettings
No i just migrated my existing app
178 replies
CC#
Created by Tiltyboi on 11/27/2023 in #help
C# IConfiguration not loading appsettings
Because: CS0117 'Host' does not contain a definition for 'CreateApplicationBuilder'
178 replies
CC#
Created by Tiltyboi on 11/27/2023 in #help
C# IConfiguration not loading appsettings
var host = Host.CreateDefaultBuilder()
.ConfigureDiscordHost((context, config) =>
var host = Host.CreateDefaultBuilder()
.ConfigureDiscordHost((context, config) =>
???
178 replies
CC#
Created by Tiltyboi on 11/27/2023 in #help
C# IConfiguration not loading appsettings
what do you mean
178 replies