Skip to main content

Questions tagged [entity-framework-core]

For questions about Entity Framework Core (EF Core) for .NET Core. Please also add a version-specific [ef-core-xx] tag, when applicable. Note that Entity Framework for .NET Framework is an older, different product that fits the [entity-framework] tag.

entity-framework-core
175 votes
9 answers
131k views

Filtering on Include in EF Core

I'm trying to filter on the initial query. I have nested include leafs off a model. I'm trying to filter based on a property on one of the includes. For example: using (var context = new ...
Jason N. Gaylord's user avatar
264 votes
22 answers
336k views

Raw SQL Query without DbSet - Entity Framework Core

With Entity Framework Core removing dbData.Database.SqlQuery<SomeModel> I can't find a solution to build a raw SQL Query for my full-text search query that will return the tables data and also ...
David Harlow's user avatar
  • 2,823
44 votes
2 answers
33k views

EF Core returns null relations until direct access

I have some models like those below: public class Mutant { public long Id { get; set; } ... // Relations public long OriginalCodeId { get; set; } public virtual OriginalCode ...
ConductedClever's user avatar
4 votes
3 answers
2k views

Can I reuse code for selecting a custom DTO object for a child property with EF Core?

When querying using Entity Framework Core, I am using expressions to convert to DTO objects, which works well for the object, and any child collections. A simplified example: Model: public class Model ...
michael's user avatar
  • 95
113 votes
21 answers
264k views

How to run stored procedures in Entity Framework Core?

I am using EF Core 1.0 in an ASP.NET Core App. Can you please point me to the proper way of executing stored procedures? The old method with ObjectParameters and ((IObjectContextAdapter)this)....
eadam's user avatar
  • 25.2k
24 votes
2 answers
6k views

EF Core Second level ThenInclude missworks

Assume having these models first: Method that has one OriginalCode OriginalCode that has many Mutants Mutant that has many ParseSubTrees Now when querying on Method I want the other being loaded. So ...
ConductedClever's user avatar
56 votes
2 answers
57k views

Entering keys manually with Entity Framework

I'm trying to use Entity Framework code first for a simple database project and I run into a problem I simply cannot figure out. I noticed EF was setting the ID for my tables automatically ...
JCafe's user avatar
  • 597
212 votes
10 answers
204k views

Get SQL code from an Entity Framework Core IQueryable<T>

I am using Entity Framework Core and I need to see which SQL code is being generated. In previous versions of Entity Framework I could use the following: string sql = ((System.Data.Objects....
Miguel Moura's user avatar
  • 38.6k
57 votes
10 answers
108k views

Dynamically change connection string in Asp.Net Core

I want to change sql connection string in controller, not in ApplicationDbContext. I'm using Asp.Net Core and Entity Framework Core. For example: public class MyController : Controller { private ...
Yurii N.'s user avatar
  • 5,623
33 votes
4 answers
25k views

Entity Framework Core 2.0.1 Eager Loading on all nested related entities

I have a simple problem, but cant seem to find a way around it. I am using Entity Framework Core version 2.0.1 and want to eager load all my entities by default. Example: public class Order { ...
Jinish's user avatar
  • 2,033
152 votes
19 answers
246k views

Entity Framework Core: `SqlNullValueException: Data is Null.` How to troubleshoot?

I am using Entity Framework Core in an ASP.NET Core application and Controller action and I haven't changed something to the working code nor to the database but I can't tell what is the query ...
Natalie Perret's user avatar
8 votes
1 answer
14k views

Avoid or control circular references in Entity Framework Core

I really am done with this, but at least I want to know what's going on. Here we go: My project is an ASP.NET Core Web Application with Code First Entity Framework Core and an Angular frontend. I want ...
user2563731's user avatar
227 votes
22 answers
296k views

.NET Core 3.0 possible object cycle was detected which is not supported

I have two entities that are related as one-to-many: public class Restaurant { public int RestaurantId {get;set;} public string Name {get;set;} public List<Reservation> Reservations {...
Nazar  Pylyp's user avatar
  • 2,373
60 votes
15 answers
86k views

.NET Core 2.1 Identity get all users with their associated roles

I'm trying to pull out all my Identity users and their associated roles for a user management admin page. I thought this would be reasonably easy but apparently not. I've tried following the following ...
Andy Furniss's user avatar
  • 3,894
26 votes
1 answer
9k views

Many-to-many self referencing relationship

I am new in EF. And I ran into a problem with creation many-to-many self referencing relation. I've tried to use solution from: Entity Framework Core: many-to-many relationship with same entity my ...
butek's user avatar
  • 363

15 30 50 per page
1
2 3 4 5
130