Questions tagged [entity-framework-5]
The ADO.NET Entity Framework version 5, containing support for .net 4.5
3,957
questions
0
votes
0
answers
25
views
EF core update many to many navigation properties
Recently I have to update EF entity with its navigation properties. I am using .NET 5 and EF 5.0. I struggled to find a good way to update all navigations properties at once and after a few hours, I ...
-3
votes
0
answers
37
views
How can I use Table-Valued function using Entity framework core in my web API?
public class Tag_ValueX
{
public int Id { get; set; }
public DateTime TarihBaslangic { get; set; }
public DateTime TarihBitis { get; set; }
}
//This is the tag valuex class
1
vote
1
answer
80
views
Using the result of ThenInclude() rather than starting at Include() again. Entity Framework Core 5
I am pretty new to EF Core, so if this question seems obvious, go easy on me :)
As the title mentions, I would like a way to simplify queries in EF core, so that I don't have to reset at the top of my ...
0
votes
0
answers
46
views
Is there any npgsqlVsix Version is Compatible with Npgsql 3.0.5 EF5 for visual studio 2017?
cant update any table to edmx, but can CRUD the database.
I have tried every version of Npgsql.Vsix and didn't work, the option I found is upgrade the EF and npgsql version, but I cant do that because ...
0
votes
0
answers
51
views
C# & EF Core 5.x AutoInclude() for many-to-many relation
Sorry for my English :)
When I am configuring a model in OnModelCreating(), I'm using AutoInclude() method:
modelBuilder.Entity(tableType).Navigation(tableType.NavigationPropertyName).AutoInclude();
...
0
votes
0
answers
37
views
why Is my Update method not letting me get Current and Original entity values on SaveChangesAsnyc override?
I have the following update method to update all fields of a record:
public async Task<TUsers> Update<T>(T updatedRecord, string operatorId) where T : BaseUser
{
var operator = await ...
1
vote
1
answer
82
views
API allowing duplicate primary key
I am bulding a Swagger API. I have tried to make my primary key unique but it doesn't seem to work. My DbContext was created by Scaffolding and I have an entity (Product) which primary key is a string....
0
votes
0
answers
124
views
Cannot insert explicit value for identity column when IDENTITY_INSERT is set to OFF with .Net 5
I just migrated to .Net 5.0 and I am getting some issues that I did not have with .Net Core 2.2
When I try to add some values in the BookAuthor mapping table, I am having the error :
Cannot insert ...
0
votes
0
answers
104
views
Entity Framework not generating models from Stored Procedure that contains dynamic SQL
Got an old legacy system that uses Entity Framework 5. I've been working alongside a SQL developer trying to update some stored procedures, and he's chosen to work with dynamic SQL.
I know that EF ...
0
votes
1
answer
168
views
Entity framework core override property issue
I have 2 classes
public class Offering
{
[Required]
[JsonPropertyName("startDate")]
public virtual DateTime StartDate { get; set; }
[Required]
[JsonPropertyName("endDate"...
0
votes
1
answer
51
views
View SQL generated by Entity Framework version 5 [duplicate]
How can I view the complete sql query generated by Entity Framework (version 5)? I can view it using
query.ToString()
but I don't get all the parameters with it. I get a lot of variables like @...
2
votes
1
answer
236
views
Entity Framework Group by based on a Nullable Primary Key column
My entity for storing address looks like below and referring to multiple tables as foreign key like country continent etc
public class ContactAddress
{
[Key]
public int Id { get; set; }
[...
0
votes
1
answer
61
views
How can I get empty months while grouping records by last 12 month in EF Core 5
I have code snippet below for grouping records for last 12 months and it works properly but I just noticed that empty months is not included. Where did I go wrong?
Thanks in advance
public IQueryable&...
-1
votes
1
answer
83
views
C# Asp.Net EntityFrameworkCore 5.0 _ManageNav.cshtml.g.cs deletes using statement on rebuild
I am doing a demo project in asp.net MVC with entityframework 5.0.
I created a custom user class that inherits IdentityUser, and replaced it in the whole project after scaffolding all identity files. ...
0
votes
0
answers
78
views
call action method by ajax with pass parameter (.Net framework core 6 or 5 )
i have an error,
i created the action method to execute the query in SQL database and when i call on it by ajax call but it include about parameter is (GUID) when i call it by ajax the parameter ...
0
votes
0
answers
30
views
EF 5: custom name for columns of join table
I'm working on moving some parts of a legacy Rails project into .NET services.
The legacy project is a Rails project. And it is still being used. And now I need to implement a relation roles - ...
0
votes
0
answers
175
views
how to mark as null a DbSet property in EF Core 5
I need these fields/properties of my entity/table to not be required
public class Oferta
{
.....
public DateTime FechaPublicacion { get; set; }
public DateTime ...
0
votes
1
answer
29
views
Entity Framework: can Include method work with a View?
I have a View in my project and I would like to retrieve all data from a table whose Ids is in the View.
Below the script to create a very simplified database (View_1 and Motors and the same but in ...
0
votes
0
answers
29
views
EF 5 With linq not working in transaction scope when mix the process
I'm making a digital signature application with an approval process, where I read the uploaded files and when I approve
I will paste the signature into the page of the received file and will send an ...
0
votes
0
answers
10
views
Entity Framework is mis-using the data
I have the following piece of code which is designed to allocate monthly fees to all of the students except those who are either Free or Struck-off. But I get the wrong result. I don't know why!
...
0
votes
1
answer
48
views
Entity Framework problem with reducing projection
I've been working on improving performance for our .NET core API with EF 5.0.11 by reducing the projection of our queries, but I'm currently stuck with the following scenario:
I improved the ...
0
votes
1
answer
64
views
EF Behavior of Last and LastOrDefault
Recently I was enhancing my knowledge with EF and to stay up to date I just went for the hole path on Pluralsight. Whith that in mind I checked out a few courses by Julie Lerman which is by the way a ...
0
votes
0
answers
40
views
How to isolate cause of Entity Framework error 2062: No mapping specified for instances of the EntitySet and AssociationSet
One of our environment databases was recently copied into a new server. We connect to that database via Entity Framework 5. When the connection string was switched over to this copy, however, we ...
1
vote
1
answer
386
views
problem with inner join in many-to-many relationships with entity framework core 5
I want to launch a query crossing two tables that are related from many to many and in entity framework core 5, it is not necessary to create the c# class of the intermediate table. So with include I ...
0
votes
0
answers
60
views
Entity Framework : the selected stored procedure or functions returns no columns
I am getting this error from Entity Framework while creating a complex type. May of them are telling to user SET FMTONLY OFF but for me it is not working. The stored procedure is returning the column ...
0
votes
1
answer
139
views
ExecuteSqlRaw() complains invalid SQL statement, but it's not
I have a call:
BackFill = "EXEC SYSDBA.BACKFILL('64907RM9')";
_context.Database.ExecuteSqlRaw(BackFill);
I have tried the statement in Oracle SQL Developer, and it works. However, when I ...
0
votes
1
answer
546
views
How to get ConnectionString from appsettings.json into DA project?
So far I developed multiple ASP.NET Core Web applications using EFCore (3.1) where I had all layers (Model, DataAccess, BusinessLogic...) in the same project. In order to provide the database ...
0
votes
0
answers
213
views
EntityFramework Core 5 does not connect to SQL Server 2008
I installed dotnet core 5 on ubuntu 21.04. I created a webapi project with VS Code and managed to run everything smoothly.
I installed EF5 to the project and am trying to connect to SQL Server 2008
...
0
votes
1
answer
92
views
ASP.NET 5 MVC with EF controllers using services
I'm new to the ASP.NET 5 MVC with Entity Framework. This is probably a simple problem, but I can't find a tutorial for this online, or I don't know how to search for it. So here's my problem.
I've ...
1
vote
1
answer
162
views
Unit of work Update problem: Entity Already another instance is already being tracked
I've a problem with my UOW pattern implementation ( my UOW uses Repository Pattern ). Im gonna try to explain my project structure with two simple calsses.
I've Person and Car, (one to many - one to ...
5
votes
1
answer
2k
views
Upgraded .Net Core 3.1 to 5 Migration No Entity Type Mapped to Table
Upgraded our application from .Net Core 3.1 to 5.0.6, and everything was working using an existing database. If I drop the database and run the migrations I get this error:
There is no entity type ...
0
votes
0
answers
312
views
Entity Framework Core 5 tries to insert value for computed column
Using Entity Framework 5 and EF Core Power Tools (whith the setting to generate ef 5 code enabled) we get something like the following code generated for each computed column:
...HasComputedColumnSql(&...
1
vote
1
answer
346
views
Mixing .NET Core and Framework in same solution - System.Data.Entity Issue
I am giving our legacy .NET 4 Framework libraries a new entry via .NET Core WebAPIs.
Unfortunately, I am stuck at an issue at runtime (while loading dependency container) in the webapi project (net ...
-1
votes
1
answer
184
views
Create an order-by Expression<Func<T>> with multiple fields
How do I create an order-by expression that involves multiple fields?
This isn't the correct syntax:
Expression<Func<Employee, Object>> orderByExpression = null;
orderByExpression = e =>...
1
vote
2
answers
255
views
Why is Sqlserver enlisting in transaction when Enlist=False?
Using entity Framework 5 (5.0.4) and a local SQL Server, why does the following code not create a row in the database?
Note that the connection string contains Enlist=False
using System;
using System....
4
votes
2
answers
3k
views
"LINQ expression could not be translated" with DateTime comparison in LINQ query?
I'm a newbie that just recently started using EF Core 5 for a project and am encountering an issue with the following query:
TimeSpan bookTimeToLive = TimeSpan.FromHours(10);
IList<Book>? ...
1
vote
1
answer
51
views
Get value of IEnumerable without having to hardcode it
I'm experimenting with adding a Razor page that will display Employees in all stores that belong under the same companies subgroup identifier. If I hard code the value .Contains("ABC") in ...
0
votes
1
answer
734
views
"Script Halted" error when trying to migrate DB in EntityFrameWork Core with NuGet console [duplicate]
My specs are: Win7 x64, VS 2019, Entity framework 5.0.2
I follow this tutorial on EntityFrameWork Core (EFC): https://www.entityframeworktutorial.net/efcore/entity-framework-core-console-application....
0
votes
1
answer
174
views
How to refresh EntityFramework core 5 model or query filter cache?
I have this query filter on tenant:
m.Builder.HasQueryFilter(mm => EF.Property<int>(mm, "TenantId") == SindikatDataSetBase.TenantId);
When I login into a desktop app as a different ...
5
votes
2
answers
1k
views
.NET Core API: PartitionKey extracted from document doesn't match the one specified in the header
Background:
I am just starting out with Azure CosmosDB and trying to make use of the Entity Framework CosmosDB provider. I have created a simple API, along with Swagger API documentation, which will ...
0
votes
1
answer
237
views
Update one row using entity framework c#
I am working on a Windows Forms Application using C# and entity framework. I put all the products that the customer bought in DGVNewOrder. for evry product in the DGVNewOrder, I want to Update(by name)...
0
votes
1
answer
47
views
How to retrieve data from multiple tables using EF 5 linq method
I am facing a problem as discussed below.
I have four tables
PateintTable
PatientRecordTable(FK=PatientID)
RecordMedicineTable(FK=MedicineID,RecordID)
MedicineTable
I want to get a specific Patient ...
4
votes
2
answers
453
views
Update-Database using Simple Injector, without services.AddDbContext<>()
.NET Core 3.1, EF Core 5.0 preview 6.
I am using Simple Injector 5.0 to register IMyContextFactory (I'm not using services.AddDbContext<>()).
My MyContext have all constructors set to private ...
1
vote
1
answer
77
views
Does EF automatically load many to many references collections
Imagine we have the following db structure
Organization
{
Guid OrganizationId
//....
}
User
{
Guid UserId
}
OrganizationUsers
{
Guid OrganizationId
Guid UserId
}
...
0
votes
1
answer
268
views
Will Entity Framework 5 run under .NET 5?
Will Entity Framework 5 run under .NET 5? I ask this because I tried to upgrade my app to EF 6 and was unsuccessful. So sticking with EF 5. Does this mean I can't go to .NET 5?
1
vote
1
answer
82
views
How to translate a query with an EntityState and a value from Entity Framework 5 to 6?
I'm migrating a system from Entity Framework 5 to 6 and I have the following query:
item.Count(x => x.ID < 0 && ((EntityObject)x).EntityState == System.Data.EntityState.Added)
The item ...
0
votes
0
answers
36
views
How do I define multiple EF DbContexts that share the same structure so they can use methods interchangeably?
I am using a single database design for 3 different SQL Server locations (production, backup, master). The design is simple, shown below for the production location:
Public Class ProductionDbContext
...
0
votes
0
answers
530
views
Logging queries in EF5
Im new with VB.NET language and i need to log all queries generated in diferent controllers (SELECTs, UPDATEs, INSERTs and DELETEs). I have tried to search about this topic but all i found it is about ...
0
votes
0
answers
136
views
C#/Entity Framework: How to only call setter, when the value changes?
I am writing bugfix code for a legacy ASP.NET application which uses Entity Framework 5. I am taking user input and update my entities using the new data.
My entities do not change much, but still I ...
0
votes
1
answer
43
views
Issue with Entity Framework and Oracle
I have an environment that uses Oracle.DataAccess.dll for Oracle 12c (ODAC is 32 bit and version is 4.122.1.0) for it's connection to the Oracle DB. In this environment, the Oracle DB is on the same ...