C
C#khamas

❔ postgres EF core, how to have a custom connection string config file

Hey, I have a net6 class library with a DbContext, I want to have the connection string in a separate custom config file, code below. For some reason, when I do dotnet ef database update, an error pops up:
System.ArgumentException: Couldn't set min pool size (Parameter 'min pool size')
---> System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary. *...*

Couldn't set min pool size (Parameter 'min pool size')
System.ArgumentException: Couldn't set min pool size (Parameter 'min pool size')
---> System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary. *...*

Couldn't set min pool size (Parameter 'min pool size')
My connection string looks like this: User ID=postgres;Password=<PASSWORD>;Host=localhost;Port=5432;Database=NetSendHost;Pooling=true;Min Pool Size=0;Max Pool Size=250;Connection Lifetime=0;
public class Db : DbContext
{
private static readonly string ConnectionString;
static Db()
{
var obj = JsonDocument.Parse(File.ReadAllText("Config/config.json"));
ConnectionString = obj.RootElement.GetProperty("PgSqlConnectionString").GetString();
}

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseNpgsql(ConnectionString);
}
public DbSet<PrivateServerUser> ServerUsers { get; set; }

}
public class Db : DbContext
{
private static readonly string ConnectionString;
static Db()
{
var obj = JsonDocument.Parse(File.ReadAllText("Config/config.json"));
ConnectionString = obj.RootElement.GetProperty("PgSqlConnectionString").GetString();
}

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseNpgsql(ConnectionString);
}
public DbSet<PrivateServerUser> ServerUsers { get; set; }

}
UU
Unknown User500d ago
K
khamas500d ago
no it's a class library, and I also want the file containing the connection string to be separate lemme try same error when I put the raw string in the options @Deleted User
UU
Unknown User500d ago
K
khamas500d ago
could you tell me what is wrong with this one if you know postgres? User ID=postgres;Password=<PASSWORD>;Host=localhost;Port=5432;Database=NetSendHost;Pooling=true;Min Pool Size=0;Max Pool Size=250;Connection Lifetime=0;
UU
Unknown User500d ago
K
khamas500d ago
Ok
UU
Unknown User500d ago
K
khamas500d ago
yeah constr was crooked thanks
A
Accord499d ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server
More Posts
❔ Using methods in Grade Statistics projectWrite a method PrintoutGrades that prints the grades. Write a method Statistics that will calculate ✅ Any modern approach to getting the calling class typename aside from using the stack frame?10 years ago I used to use the stack frame to go backwards and get what class is calling my current ✅ How can I hide buttons inside a tablelayout?When i make the visible false, they still show, and if i make the visible false on both the tablelay❔ How to reverse engineer your simple console app code?Just curious. Is this possible with programs like x64dbg or... ?❔ Ef Core Constructor problemHello its my first big project with ef. I have an class with 3 attributes and one constructor that i❔ many to many database cant update the 3rd tablecant update the 3rd table who had the cust id and drink id✅ rest requests helphello i am trying to send to os command injections with RestSharp to dvwa for pentestering can someo❔ Source generator, generating type script definitions at compile timeI would like to make a automatic type script definition from code, i consider to use source generato❔ Making an async method without anything to async insidelet's say i have following scenario: ```csharp void Foo() { for(int i = 0 ; i < 10000000 ;i++){} /❔ Reading file from the folder where .csproj isHow can i read files from folder where .csproj is? just like webapps allow to do, they do not copy f✅ Interoperability between incompatible typesHi! I'm trying to pass a class back-and-forth from C# to CPP. This class contains some members that ❔ Set item to null inside a listHey! I am trying to remove some items from a JSON object (created like `var model = new ObjectModel{Refactoring long if statement that checks for user rolesHi, I'm trying to find a cleaner way of refactoring this if code block that checks for each user rol❔ IEnumerable and dependency injectionif i want to loop enumerable from DI multiple times ``` var foos = services.GetRequiredService<IEnum❔ How did you learn . NET ?Books /youtube/udemy /other courses, what resources made you learn .NET to use as your job as web de✅ Is it possible to disable these properties on EF6? Web API 2 project, multi-layered, NF472SCENARIO - Solution type is NET Framework 4.7.2 (it is, what it is). - I have this project, I'm cons✅ This EntityFramework query can not be translated for SQLiteThe issue lies within `Intersect`. The point of the query is to fetch the current user, and to popul✅ Detect Network RequestI want make service that detect all connection to specific domain or ip? And if this request contain❔ CORS errorHello, I have Cors error on my project. I add Addpolicy in my configureServices and also add app.Us❔ Ambiguities? How?Idk how i can resolve this i don't see the problem