hawk4031
hawk4031
CC#
Created by hawk4031 on 3/30/2024 in #help
EF Core and environment variables
Ok cool I got it! I create a new class implementing IDesignTimeDbContextFactory that could read the environment variables and it's able to properly create the design-time DbContext and do what I need it. Thanks for your help @ded
15 replies
CC#
Created by hawk4031 on 3/30/2024 in #help
EF Core and environment variables
One thing I'm going to try now is using IDesignTimeDbContextFactory
15 replies
CC#
Created by hawk4031 on 3/30/2024 in #help
EF Core and environment variables
I think my library versions are matched up properly according to the Npgsql documentation. I also tried the second answer in that post, but it doesn't make any difference there either.
15 replies
CC#
Created by hawk4031 on 3/30/2024 in #help
EF Core and environment variables
I'll point out that I did recently upgrade this project from .NET 6 to .NET 8. In .NET 6, there were no problems but I haven't done any migrations or SQL script generations since the change.
15 replies
CC#
Created by hawk4031 on 3/30/2024 in #help
EF Core and environment variables
It looks something like this (I took out the DbSets and entity builder stuff because it's probably not relevant here) https://gist.github.com/hawk4031/b4366ef32fea0265921d6e88e2beae45 I'm adding the dbcontext in the startup file with services.AddDbContext(). I'm also making use of the environment variables there to build up the connection string and set it with UseNpgsql(connectionString).
15 replies
CC#
Created by hawk4031 on 3/30/2024 in #help
EF Core and environment variables
Ok so maybe there isn't an issue around the environment variables because I'm still getting the other after even after the addition of that boolean. The error is nice and vague Unable to create a 'DbContext' of type ''
15 replies
CC#
Created by hawk4031 on 3/30/2024 in #help
EF Core and environment variables
I put that in my Main method in Program.cs and it makes no difference
15 replies
CC#
Created by hawk4031 on 3/30/2024 in #help
EF Core and environment variables
Interesting. Let me look into that.
15 replies