Skip to main content
Filter by
Sorted by
Tagged with
0 votes
1 answer
34 views

I am writing a Web API endpoint, data comes from SQL Server, and I'm using EF Core 8.0. I have a table of products and another table that maps the product codes to product attributes (one-to-many) ...
pepr's user avatar
  • 21.1k
1 vote
0 answers
67 views

Learning EF Core, I am changing my mind on how to get the list of products with additional information (here symbolic code) -- see the loosely related (abandoned approach) at How to conditionally ...
pepr's user avatar
  • 21.1k
1 vote
1 answer
105 views

I am trying to run my database code, but I keep getting this error and I've done whatever I can think of to fix it, whether it is random posts, or chatgpt, but I can't seem to figure it out. The ...
Hockaj's user avatar
  • 11
Best practices
0 votes
4 replies
69 views

I'm building an e-commerce application with ASP.NET Core Web API using Entity Framework Core and ASP.NET Core Identity. I have a BaseEntity class that tracks audit information (who created and last ...
Jinn's user avatar
  • 1
-4 votes
2 answers
201 views

My understanding of C#'s null safety features (from C# 8.0 onwards) is that (possibly) null variables must be typed as nullable and that the compiler will statically detect any parts of the code which ...
ducksforever's user avatar
Best practices
0 votes
2 replies
67 views

I am currently developing a module for an ASP.NET Core Web API that uses EF Core to talk to MySQL. The problem is I have no idea how to make EF Core fill the entityId property. Here is the example ...
Sannnekk's user avatar
  • 103
1 vote
1 answer
92 views

I have two tables Products and CustomerProduct. I need to compose an Entity Framework Core object that returns the result based on arguments of the Web API endpoint method. The method roughly works ...
pepr's user avatar
  • 21.1k
0 votes
1 answer
107 views

I'm using EF Core 9 and I'm trying to run a migration against a copy of our production database. On our local development databases everything works, but on the production copy the migration fails ...
heaxyh's user avatar
  • 633
0 votes
1 answer
101 views

Is it possible to have a type in Entity Framework Core that doesn't create FKs to every other table that uses it? Creating the DB-Scheme from the C#-model with Add-Migration and Update-Database. For ...
Ramzi Khahil's user avatar
  • 5,106
1 vote
0 answers
53 views

I've been struggling for two days with a PostgreSQL enum type issue in Entity Framework Core. Despite all my configuration, EF Core keeps trying to send a string (`text`) to an enum column. The ...
Мирон Никитин's user avatar
0 votes
2 answers
82 views

I am trying to link a many-to-many relationship without any intermediary class in my domain. The link is SoundProfiles <-> Switches. They're both not required. The error I get is One or more ...
Yves Schelpe's user avatar
  • 3,513
0 votes
1 answer
100 views

I have a web app using code-first EF Core. One of the controllers needs to run what should be a simple query (basically SELECT TOP 1 * FROM companies WHERE id = @id; in EF terms, var data = await ...
minnmass's user avatar
  • 261
1 vote
1 answer
94 views

I'm getting this error : Unable to create a 'DbContext' of type 'AppDbContext'. The exception 'Object reference not set to an instance of an object.' was thrown while attempting to create an instance....
Eray Bal's user avatar
1 vote
1 answer
103 views

Microsoft have changed ExecuteUpdateAsync to accept non-expression setters parameter in NET 10. Now it works this way: await context.Blogs.ExecuteUpdateAsync(s => { s.SetProperty(b => b....
Stanislav Gordenko's user avatar
17 votes
4 answers
5k views

I’m trying to install the Entity Framework Core CLI tools globally using the .NET CLI command: dotnet tool install --global dotnet-ef However, the installation fails with the following error message: ...
tutte2k's user avatar
  • 391
-2 votes
0 answers
54 views

Given a class A, and a class B, where class A holds a reference to class B, and where some logic in A depends on some state in B, how can i configure EF Core to make sure B has not changed when ...
Claude Hasler's user avatar
Advice
2 votes
3 replies
113 views

Do you know if EF Core correctly processes queries that apply filters and paging and select data from tables with one-to-many relationships when .AsSplitQuery() is used? If you go here: https://learn....
boggy's user avatar
  • 4,077
Advice
0 votes
5 replies
105 views

I have the following use case: the database contains a row with a nullable column, and I would like to request only that column value from the database for a single row. This can easily be done using ...
R. Hoek's user avatar
  • 1,135
2 votes
1 answer
184 views

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 ...
user1474992's user avatar
2 votes
1 answer
85 views

I just got my .Net 9 Maui app working with EF Core and SQLite. I have one row of data in the database that looks like this: I have a simple query that runs when the app loads. The repository method ...
USMC6072's user avatar
  • 832
3 votes
1 answer
111 views

I'm creating a self-contained publish of my ASP.NET Core application. When I run it on my development machine, everything works correctly: the app can connect to the remote SQL Server and db.Database....
AbdAlmalek Mokresh's user avatar
0 votes
2 answers
89 views

I'm trying to configure a new Maui app to use EF and Sqlite following this guide: https://learn.microsoft.com/en-us/dotnet/maui/data-cloud/database-sqlite?view=net-maui-9.0 For a long time I got an ...
USMC6072's user avatar
  • 832
3 votes
3 answers
121 views

How do you delete rows in tables using Entity Framework (Core), when you have two tables that are referencing each other in both directions? Consider there classes: public class ImageSeries { int ...
haagel's user avatar
  • 2,758
1 vote
1 answer
66 views

I have a simple DbFunction to convert a date string column (mm-dd-yyyy) to datetime before ordering. The DbFunction is set up in the DatabaseContext class as follows. [DbFunction("...
FLash's user avatar
  • 804
2 votes
0 answers
102 views

I'm connecting to an Oracle database using EF Core. When scaffolding the database (Scaffold-DbContext), EF Core automatically maps columns of type NUMBER(1,0) to bool. To avoid this, I changed the ...
Yafa's user avatar
  • 21
3 votes
2 answers
126 views

I'm building an ASP.NET Core Web API where I need to upload a file to Azure Blob Storage and update an EF Core entity in a single request. The challenge is that EF Core supports transactions, but ...
Codisattva's user avatar
1 vote
2 answers
122 views

I have the following classes in my (code-first) Entity Framework Core database schema: public class User { public int Id { get; set; } // ... Irrelevant bits omitted } public class Church { ...
In Hoc Signo's user avatar
2 votes
1 answer
128 views

I'm working on a .NET 8 project using Microsoft.EntityFrameworkCore 8.0.7 with PostgreSQL as the database. I have a table that contains a jsonb column, and I'm using AutoMapper to map a DTO to the ...
Alparslan ŞEN's user avatar
1 vote
1 answer
184 views

I have the following interface signature that I want to use for a more efficient bulk update using EF Core 8.0.6 using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Query; using ...
Josh's user avatar
  • 2,088
7 votes
1 answer
205 views

I'm trying to use Linq to generate a SQL command like this return await query.GroupBy(x => new { Id = x.xId, ...
A.C.'s user avatar
  • 93
3 votes
2 answers
123 views

I have a project that has uses a database-first approach. I have used db-scaffold to create the models and have also created 'custom' models to contain extra info and code. I have a model class ...
Paul's user avatar
  • 33
4 votes
1 answer
374 views

Have a rather simple LINQ query: var objectExternalIds = new string[] { "abc" }; var query = from order in Context.Order join apointment in Context.Appointment on order.Nr equals ...
Jester's user avatar
  • 3,411
1 vote
1 answer
113 views

I just added an EF entity called PurchaseOrderProduct, which creates a many-to-many link between my PurchaseOrders and Products. [PrimaryKey(nameof(PurchaseOrderId), nameof(ProductId))] public class ...
Jonathan Wood's user avatar
0 votes
0 answers
58 views

I have a nested entity, defined like this: entity.OwnsOne(e => e.EncryptedElements, o => { o.ToJson(); o.OwnsMany(x => x.Values, o => { o.Property(x ...
ZorgoZ's user avatar
  • 3,758
6 votes
3 answers
210 views

I have a SQL Server database I mostly interact with using EF Core in a .NET project: I'll analogize my domain logic for simplicity. I have a Fruits table holding general fruit data in columns Weight, ...
Mr. Kloud7's user avatar
2 votes
1 answer
56 views

The entities are: public class Department { public int Id { get; set; } public string Name { get; set; } public IList<Employee> Employees { get; } = new List<Employee>(); } ...
yogihosting's user avatar
  • 6,386
0 votes
2 answers
82 views

I need to rewrite the code for getting and filtering the list of products. The older version used directly the SQL table Products, and filtered the result by code or name of a product, category, etc, ...
pepr's user avatar
  • 21.1k
3 votes
1 answer
253 views

I am trying to project the result of the following query into EF Core 8 entities: select foo.* , (case when hst.Id is not null and foo.OtherColumn = 1 then 42 else null end) as Bar ...
Ian Kemp - SO dead by AI greed's user avatar
2 votes
1 answer
57 views

I am facing this problem at migration - here are my model classes: // Principal (parent) public class Blog { public int Id { get; set; } } // Dependent (child) public class BlogHeader { ...
user2843511's user avatar
1 vote
2 answers
244 views

I have a code snippet that uses let with a where clause. private List<string> Example2() { var query1 = from c in _context.Customers let custPurchases = _context.Purchases....
Romanov Nikita's user avatar
1 vote
0 answers
239 views

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 '...
Andres Miguel Campos's user avatar
0 votes
1 answer
100 views

I have the following entities Film: using System.ComponentModel.DataAnnotations.Schema; namespace MyWebAPIApplication.Entities { public class Film : Base { string Title { get; set; } ...
James's user avatar
  • 1,345
1 vote
1 answer
97 views

I've got a class model with two principal classes (PrincipalEntity1, PrincipalEntity2) which are both related to the same child entity (TwiceDependentEntity). PrincipalEntity2 is related directly to ...
kjeld-jensen's user avatar
1 vote
0 answers
89 views

I am very new to development with ORMs. In my project, where I use Entity Framework Core, I want to create a class that would encapsulate whole interaction with database, i.e. through which I would ...
Alex's user avatar
  • 11
0 votes
0 answers
123 views

When setting the value on the entity, it works as easily as assigning an empty collection to the property. The property has converters to-from JSON. However, both throw exceptions: await db....
ZorgoZ's user avatar
  • 3,758
2 votes
1 answer
374 views

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):...
Alparslan ŞEN's user avatar
0 votes
0 answers
43 views

When I ran a scaffold command on my NPGSQL db with the typical default format I find on the web: Scaffold-DbContext <connection-string> OutputDir Models -Force It created all my model classes ...
Trant's user avatar
  • 3,651
1 vote
1 answer
564 views

private readonly IMapper _mapper; public CreateDepartmentRequestHandlerTests() { var config = new MapperConfiguration(cfg => cfg.AddProfile(new CreateDepartmentProfile())); _mapper = ...
Saidabror's user avatar
3 votes
1 answer
274 views

I'd like to rename a table in Entity Framework Core, code first. I do not want to drop and create the table, as this would lose all my data. As I search for information on this, I see that the vast ...
Jonathan Wood's user avatar
1 vote
0 answers
67 views

In Entity Framework Core 9.0.9, the query builder fails with SQLite Syntax builder.Services.AddDbContext<MyDbContext>(fun options -> options.UseSqlite(connectionString) |> ignore It ...
Kalju Pärn's user avatar

1
2 3 4 5
471