3,308 questions
2 votes
1 answer
179 views
.NET migrations with vulnerabilities
I am attempting to create a new EF Core migration using the add-migration command in the Visual Studio Package Manager, but the command is failing with the following error: The running command ...
1 vote
0 answers
46 views
EF Core 8.0.5 migrations not creating tables in Release publish (only raw SQL via migrationBuilder.Sql() executes) [closed]
I have an ASP.NET Core application using Entity Framework Core (SQL Server). When I run the app in Debug, all migrations execute perfectly — all tables are created in the database as expected. However,...
1 vote
0 answers
237 views
Unable to create a 'DbContext' of type 'RuntimeType'
I get this error when migrating from Entity Framework: dotnet ef migrations add initApp Unable to create a 'DbContext' of type 'RuntimeType'. The exception 'Unable to resolve service for type '...
2 votes
1 answer
373 views
How can I automatically apply custom naming conventions for PK, FK, index, sequence and default column values in EF Core migrations?
I am using Entity Framework Core and I want to enforce custom naming conventions automatically for PKs, FKs, indexes, and sequences during migrations. My naming rules are as follows: Primary key (PK):...
1 vote
0 answers
40 views
DB creation fails through the Azure web app with Azure Postgres Flexible Server
I have an Azure Postgres flexible server sitting in a VNet divided into multiple subnets. In a distinct subnet lies an azure app service I am trying to run by publishing it via gitlab. However shortly ...
0 votes
1 answer
99 views
How can I use existing PascalCase entity classes with EF Core scaffolded context that expects lowercase class names?
I'm migrating a .NET Framework project using EF 6 to EF Core with .NET Standard 2.0. My original EF 6 setup created lowercase, plural table names in the database, but I have manually-created entity ...
1 vote
0 answers
99 views
EF Migration not working: Unable to find SQL Server Connection String when using AddDbContextPool instead of AddSqlServerDbContext
I am trying to generate EF Migrations in a .NET Aspire project. I am following the migration example in the documentation. Everything works well with this: builder.AddSqlServerDbContext<...
0 votes
0 answers
166 views
Why the 'GetPendingMigrations()' method brings already applied migrations?
Im using EF Core in a .NET 9.0 Web API project, and I was trying to implement automatic migrations on API startup. The current project makes use of Docker containers (Configured using a Docker compose ...
1 vote
1 answer
140 views
EF Core migration conflicts between develop and feature branches (code-first approach)
We're using Entity Framework Core with the code-first approach, and our application has multiple active branches: develop (main integration branch) feature/x (feature-specific branch) Both branches ...
1 vote
1 answer
116 views
EF Core migrations add never completes
I'm trying to generate a migration script for my ASP.NET Core 9 Web API. I have 2 separate database contexts, AdministrationContext and CodebookContext. CodebookContext contains only one entity, as ...
1 vote
1 answer
165 views
Slow builds in Visual Studio because of migration files
I have a web app solution in Visual Studio 2022 that always takes at least 5 minutes to build, and I need a way to speed this up. In the solution I have a data project that includes my EF Core ...
0 votes
1 answer
152 views
.NET 8 EF Core: Can't run Update-Database — shows pending changes even when there are none
I'm working on a .NET 8 project using Entity Framework Core with PostgreSQL. When I run: Update-Database I get the following error: The model for context 'ApplicationDbContext' has pending changes. ...
0 votes
0 answers
32 views
EF Core 9.0.3: Naming field of object with relation to parent object similarly to parent-object-primarykey, omits similarly named field
I have two Objects in a one-to-many relation: User on the many and DBConnector on the one side. Users primary Key is Username. DBConnectors primary Key is DBConnectorId. DBConnector has a separate, ...
0 votes
2 answers
65 views
How to create two table from one class by EF Core
I have a class for users : public class users { public int UserId { get; set; } public string UserName { get; set; } // .... } I want to create a table called users. I write this line in ...
0 votes
1 answer
220 views
Defining the order for an existing table using EF Core and migrations [duplicate]
I'm trying to set up a new Blazor project and want to add a SQL Server database to it, which I'm configuring using Entity Framework Core and migrations. I have a simple class User with some basic ...