zzz projects Entity Framework Core EF Core
Home Articles Knowledge Base Online Examples
  • Home
  • Articles
  • Knowledge Base
  • Online Examples

Entity Framework Core - Knowledge Base (KB)

6642 results

Entity Framework get SUM from child property

I have the following model where I'd like to get the sum of all OrderTotalItems for all Orders of a Customer where the OrderTotalType (Enumeration) is "total" or 99:...public class Customer { ... public ICollection<Order> Orders { get; set; } = ne...
c# entity-framework entity-framework-core
asked by Igotcha

A possible object cycle was detected which is not supported. This can either be due to a cycle or if the object depth

i have 2 table . ...Product and Category ....Category :... public string CategoryName { get; set; } public ICollection<Product> Products { get; set; } ...Product :... public string ProductName { get; set; } [Required] public string Produ...
asp.net asp.net-core c# entity-framework entity-framework-core
asked by mr coder

Is it okay to initialize/seed a database data during Startup of an application?

We would like to programmatically ensure that a database table has a certain set of rows (based on a sometimes-changing enum). We are using EF Core 2.2 with code-first migrations and are looking for the right place to seed this data. We had thought that a...
.net-core asp.net-core entity-framework-core entity-framework-core-2.2
asked by NSouth

Unable to track an instance of type in .Net core?

I am getting below error for one of the tables. the table doesn't have a primary key. How to handle this? I am trying to add new row to the table....Error ...Unable to track an instance of type 'CommonDataZipInfo' because it does not have a primary key. ...
.net-core c# entity-framework entity-framework-core
asked by James123

Entity Framework Core Linq query doesn't translate to correct SQL statements

So I am debugging our application which uses Entity Framework Core 2.1.14. I created my entities from database first by scaffolding. Database is MySQL 5.7.29, the SQL data provider for EF Core is Oracle's MySql.Data.EntityFrameworkCore 8.0.19....Example: ...
entity-framework-core mysql sql vb.net windows
asked by Lenard Bartha

Entity Framework Core: foreign key was set and is recalled as null

I start out by generating a refresh token and storing it in SQL Server via Entity Framework Core as follows:...var refreshToken = new RefreshToken { User = user, Token = Guid.NewGuid().ToString() }; _context.RefreshTokens.Add(refreshToken); _context.SaveC...
asp.net-core-webapi c# entity-framework-core
asked by user1899938

Linq inner query in join with entity framework, query error

I'm trying to mimic this SQL query for which I'm getting the expected results: ...In Linq query, but I'm getting some errors. This is my Linq translation: ... var customerAircraftVM = await ( from ca in _context.CustomerAircrafts ...
entity-framework entity-framework-core linq linq-to-entities linq-to-sql
asked by Laziale

How to add data and remove same data from other table in asp.net core?

I am trying to remove the same row from the existing table PendingTestResult which is added in TestResult table. but it's not working kindly help me out to resolve this...this is controller ... [HttpPost] [Route("Reception/PatientTests/SaveTestResult"...
asp.net-core asp.net-core-2.0 entity-framework-core
asked by SK jha

Specify Azure SQL server edition in EF Core without breaking local development

Entity Framework Core introduced the methods ...HasServiceTier... and ...HasPerformanceLevel... to change the edition of an Azure SQL server. You can use them in ...OnModelCreating... like this:...protected override void OnModelCreating(ModelBuilder model...
azure c# entity-framework entity-framework-core
asked by Tim Pohlmann

How to map foreign key property to database in EF6 automatically

In my database I have two tables:...Scenario...:...Id Name Location_Id ...Locations...:...Id Name ...So ...Scenario... has a foreign key to ...Locations.......In the code I have this:...Scenario.cs:...public int Id { get; set; } public string Name { get; ...
c# entity-framework entity-framework-6
asked by Martijn

Look up an Id and return a string value

I have a .NetCore 3 Entity Framework controller that returns an object like this:...var games = await _context.Game .Select(x => new GameEntity { Id = x.Id, Title = x.Title, GameCharacterClasses = x.GameCharacterClasses })....
asp.net-core asp.net-core-3.0 c# entity-framework-core
asked by SkyeBoniwell

Entity Framework Core and complex value-object

I'm trying to model an entity with a complex value object....The database structure could be something similar to this:...+-------------------------------------+ | car | +----------------------+--------------+ | id ...
entity-framework entity-framework-core
asked by Marc

How to send post request for related data from angular to .NET core api

I'm new to angular and .NET core, I'm trying to store related data to sqlserver via .net core api. My problem is Order controller is receiving one Order object how It will store orderitems with same OrderId which will be generated in Order Table? Plus I'm...
angular asp.net-core asp.net-core-webapi entity-framework-core
asked by Khizar Murad

How to add DBContext to services from another assembly

on .net core 2.1, I have loaded the assembly to the application using ...services.AddMvcCore().AddApplicationPart([Assembly]) ...But the assembly contains its DB context , the problem is that I am not able to load the DBContext from the assembly, in a si...
asp.net-core c# entity-framework-core reflection
asked by Mosta

EF Core Data is Null

Most of the answers on this state that the DbSet on the context must be a property. However that does not seem to be the case in this instance since the DbSet of this context is a property. Here is the sample code that I can use to recreate the problem. P...
c# entity-framework-core xunit
asked by user433229

Connection Refused error on Postgres database creation using Npgsql Entity Framework Core

I am trying to create and use a PostgreSQL database with my .NET Core application. I'm using Entity Framework Core provided by Npgsql, and I'm going for the 'code-first' approach. However, when I try to generate the database (using either migrations or th...
.net-core c# entity-framework-core npgsql postgresql
asked by McFlyboy

Nullable reference types and constructor warnings

I'm trying to embrace C# 8's nullable references types in my project and make it smoothly work with EF Core....Following ...this guide..., I made my entity classes have constructors accepting all data needed for initializing their non-nullable properties:...
c# c#-8.0 constructor entity-framework-core nullable-reference-types
asked by Павле

How to auto increment Id with VARCHAR or NVARCHAR in Entity Framework Core?

I used to do that using a compound column in my SQL code before....[ID] [int] IDENTITY(1,1) NOT NULL, [PreFix] [varchar](50) NOT NULL, [EmployeeNo] AS ([PreFix]+ RIGHT('0000000' + CAST(Id AS VARCHAR(7)), 7)) PERSISTED,
asp.net asp.net-core entity-framework entity-framework-6
asked by Jawed Khalil

Replacing an array of ints with an array of strings when returning a collection inside a linq query

I have an Entity Framerwork API controller that returns a list of objects called 'systems'. ...In that object, I have an ICollection property called StarSystems that is a collection of ints that represent string names....Instead of returning the array of ...
asp.net-core c# entity-framework-core linq
asked by SkyeBoniwell

EF Core: fetch two SELECT statements in a single call by FromSql()

I have the following SP in which a number of rows and the total number of rows are fetched. How is it possible to call the SP and fetch its content (the 2 SELECT's)?...-- A very simple SP CREATE PROCEDURE dbo.Sample AS BEGIN SELECT TOP 10 c.Id, s.Creati...
ef-core-2.2 entity-framework-core sql-server
asked by Behzad Rezaie

Page 331 of 333
  • ««
  • «
  • …
  • 324
  • 325
  • 326
  • 327
  • 328
  • 329
  • 330
  • 331
  • 332
  • 333
  • »

Prime Library

Performance

  • Entity Framework Extensions
  • Entity Framework Classic
  • Bulk Operations
  • Dapper Plus

Expression Evaluator

  • C# Eval Expression
  • SQL Eval Function
More Projects...

Related

  • EF Extensions Online Benchmark
  • WIN an EF Extensions license
  • EF6 BatchSaveChanges for only $79
Get monthly updates by subscribing to our newsletter!
SUBSCRIBE!