Questions tagged [entity-framework-4]
A tag for ADO.NET Entity Framework 4.x, itself an object-relational mapping for the .NET framework.
7,390
questions
0
votes
0
answers
18
views
How can i bind same column in DbModelBuilder for IdentityUser's two different properties
This is my table
SELECT TOP (1000) [Id]
,[Adi]
,[SoyAdi]
,[Maili]
,[Sifresi]
,[Adresi]
,[Telefonu]
,[KurumAdi]
,[VergiNo]
,[VergiDairesi]
,[...
0
votes
0
answers
22
views
how to make a relationship between 3 tables using the Join() method and using two values as a rule Entity Framework
I trying to join 3 tables and I need to compare two values to make the first relationship, and make the second relationship based on that.
But I don't know how to use the Join() method to do that.
I ...
0
votes
1
answer
60
views
Linq to SQL: GroupBy() and Max() to get set of data
Consider a table with the following schema
Table Schema
I would like to fetch data from each Status where category is max
In '1' Status, max category is 2, so fetch all rows of category 2
In '2' ...
0
votes
1
answer
30
views
Migrate from EF to EF Core. Unloaded entity in the For Loop
We embark on a journey to migrate an existing EF4 project to EF7.
We stumbled upon a leak that will lead to many undetected bugs (no build errors).
In the EF4 project, we rely on Lazy Loading to get ...
0
votes
0
answers
55
views
How to use translate Max(value) and Group By (Value/100) in VB LINQ?
I'm currently stuck trying to translate a "simple" SQL Query to a LINQ Query in VB.
Here's my Table :
SELECT ID_FRUIT, MAL, numero
FROM MyTable
where ID_SITE = 9 AND ID_DRT = ...
0
votes
2
answers
69
views
C# MVC with Entity Framework Database Initializer failing
Im working on a website as a leaning tool and have run into an issue where entity framework fails to set the database initializer. This is the error I am getting:
System.InvalidOperationException
...
-1
votes
1
answer
46
views
Is it possible to compare with a number in "Where"?
I am new in Entity Framework and I have a little question.
Is it possible to compare in "Where" with a number.
I will add code example.
var source = db.Book.Where(book => book.Count > ...
0
votes
0
answers
154
views
Function mapping in Entity framework
So, I am working on an already existing application. The application has implemented a DB first approach. I recently updated a stored procedure. I updated the same stored procedure in the EDMX file, ...
1
vote
1
answer
742
views
EF Core - problem with inheritance from table and use primary key in the next table
I tried to create database using TPT. I have nine entities but when i launch DbInitializer its give me following exception
"System.InvalidOperationException: 'The instance of entity type 'Boss' ...
0
votes
0
answers
146
views
Entity Framework Datetime Conversion
I'm trying to get some records from my table (DB: Oracle) by using Entity Framework lambda expression and I have only one date property to filter records (DiscussionDate > DateTime.Now).
However, ...
0
votes
1
answer
807
views
How to use older version of Entity Framework when updating Model
I am working on a Web application which uses Entity Framework 4.1.10331.0.
I have made couple of changes in DB and now I need to update the model (Entity Model/EDMX) in Visual Studio, but when I ...
0
votes
1
answer
669
views
Entity Remove() is setting foreign key properties to null
I have a One-to-Many relationship as shown below - the child in the relationship is soft-deleted and the string foreign key is non-nullable/[Required] however I'm having issues when I try to remove ...
0
votes
1
answer
600
views
Passing empty DataTable to SQL Server stored procedure through database context
I am trying to pass empty DataTable to a SQL Server stored procedure but I am getting error executing it. The error is:
There are not enough fields in the Structured type. Structured types must have ...
0
votes
1
answer
253
views
Improving performance of Linq to SQL list intersection
I've got some working code here but I'm really concerned that it's not efficient - but I can't think of a way to improve it. Any thoughts?
We have IQueryable<Users> users, which gets its data ...
-1
votes
2
answers
343
views
The type of one of the expressions in the join clause is incorrect. Type inference failed in the call to 'Join'.- Linq JOIN with multiple condition
This might get closed for a possible duplicate of this: The type of one of the expressions in the join clause is incorrect in Entity Framework
But I would request to not close this without reading ...
0
votes
2
answers
82
views
How to refactor the connectionString in my Entity Framework & ASP.NET MVC project?
I have a large number of stored procedures to work with and I have to work with Entity Framework.
I got for example this controller where I'm just calling the database to show my table:
public class ...
0
votes
1
answer
221
views
How to return DataSet in EntityFramework 4
I have this method that returns obj Data, but instead of that I need to return DataSet
public static Data GetData(int id)
{
var result = new Data();
using (var context = new MyContext(false, ...
0
votes
0
answers
308
views
Update model from Firebird database
I would like to update model from a Firebird database in Visual Studio. I followed this tutorial: https://www.ibprovider.com/eng/documentation/...
0
votes
1
answer
391
views
How to generate default sql value in entity framework code first migration file
We have defined a base class as
public class BaseSchema
{
[Key]
[ScaffoldColumn(false)]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
...
1
vote
0
answers
175
views
Upgrading legacy Entity Framework 4.0 to 5.0
We have a .NET Framework 4.0/WPF application that was recently updated to .NET Framework 4.8. As part of this same round of updates, we also wanted to upgrade our Entity Framework libraries.
Our ...
0
votes
1
answer
25
views
Entity Framework Refuses to Show Which Column is "broken"
This post is going to be riddled with problems. I know we do EF wrong. I know the way we do EF is abominable. Now that that's out of the way:
We have a number of very legacy code bases that use DB ...
0
votes
0
answers
159
views
How do I update my Model without updating the EF version?
I am working on a Legacy project which uses "EF4.0" (system.data.entity version 4.0.0.0 runtime version v4.0.30319.
There are many places in the project where properties on "context&...
0
votes
0
answers
75
views
Add only required stored procedures to EDMX
I have two newly created stored procedures in my database. I tried to import those two stored procedures by going to Model Browser -> Function Imports -> Update Model from Database -> Add (...
1
vote
0
answers
30
views
Slow EF 4 query with Include and joins
I have following EF 4 query which takes about 7 to 8 minutes.
List<SecureDevice> tempSecureDevices = objectContext.SecureDevices.Select(x => new
{
SecureDevice = ...
0
votes
1
answer
60
views
Unable to refer in namespace the class library in it ado.net entity data model .edmx in asp.net web application webapi
I have a classLibrary Project(. Net Framework 4.6.1) namely 'EmployeeDataAccess', it contains an ADO.Net Entity Data Model (.edmx) configured successfully to my SQL-server. I have a separate ASP.Net ...
0
votes
1
answer
46
views
The specified type member 'Date' is not supported in LINQ to Entities. DbFunctions.TruncateTime()
Question question =
db.Questions
.Where(q => DbFunctions.TruncateTime(q.Day.DayDate) == DbFunctions.TruncateTime(DateTime.Now.Date))
.Where(q => q.Order == id)
...
1
vote
2
answers
10k
views
Multi tenant application with ASP.NET Core 3.0 and EF Core
I'm developing a multi-tenant based application that will have a separate database for each school/tenant. Each schema will be identical to each other. The idea is to have one database context using ....
0
votes
1
answer
1k
views
Linq query with where clause on related data
I have a data context using two SQL tables ( A and B) that are queried using the following code:
var query = from b in _ctx.A
.Where(b => b.Flag ...
0
votes
1
answer
44
views
EntityDbContext SaveChanges : What are the differences between these two codes?
In order to performance, exception capturing and etc., What are the differences between these two codes:
int count = 0;
foreach (var record in SomeDbEntityList)
{
...
0
votes
3
answers
855
views
Error while trying to exec stored procedure parameters Entity Framework EDMX model in C#
I am trying to execute my stored procedure which takes 13 parameters and some can accept nulls and some are always required. I am getting an error for 2 date parameters that do accept null.
I am ...
1
vote
1
answer
66
views
Validation failed for one or more entities issue
This is truly one of the strangest issues I've run into.
I have a Web API which uses EF. I have an audit table which takes an ApplicationUser. I create the new object, add it to the collection and ...
1
vote
2
answers
1k
views
Entity Framework slow after upgrade from EF4 to EF6 (EntityFramework.6.2.0)
I'm upgrading an old MVC web application from EF4 to EF6 (and MVC3 to MVC5) using a guide i found on SO.
Functionally appears OK, but I've noticed performance issues.
Specific requests on the ...
0
votes
1
answer
554
views
Auto mapper : Mapping two objects Ignoring few properties dynamically
For update using entity frame work , I have a DTO exposed to user with all properties but few properties are assigned with values.
Example
public class Employee
{
public int Id {get;set;}
...
0
votes
1
answer
413
views
Can we set dynamically the Command TimeOut by on query execution time in entity framework?
Can we set dynamically the Command TimeOut is "Time of the query execution" in entity framework?
0
votes
0
answers
106
views
Unused table columns are required to declare in Entity Framework objects class as properties?
I have table called Message in my database, initially we are using Entity Framework for CRUD operation with the database, after sometime we are using stored procedures due to business logic purpose.
...
0
votes
0
answers
173
views
How to add a table to Entity Framework 4 on a project with no EDMX file
I have a preexisting project that I am updating, and part of this update requires the use of a new table. The previous developers seem to have used Entity Framework, however, there is no EDMX file.
...
0
votes
0
answers
166
views
Entity framework with foreign keys runs extremely slow
Came across an Entity Framework code that creates objects with sub-objects using foreign keys from the DB.
The generated SQL query is immediate but the EF code runs forever...
1.checked that the FK ...
0
votes
1
answer
2k
views
Read Oracle SYS_REFCURSOR in C# Entity Framework?
I have a simple C# console application and its code is like this:
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Linq;
using System.Text;
...
0
votes
1
answer
69
views
How to upgrade Database First Entity Framework 4 To 6
Currently I am using EF 4 with Database first approach and now want to upgrade this to EF 6.
I have seen different sources but explains only the code approach but I want to know database first.
What ...
0
votes
1
answer
113
views
How to avoid retrieving relational objects within relational reference loop using Entity Framework?
I'm trying to correctly design the structure of an Api controller method with the following object as a return type:
var obj= new CustomObject
{
...
0
votes
1
answer
1k
views
ASP.NET MVC Auto generate integer number
Good day, a really newbie developer here.
I Have a form and it have a entity of "QueueNumber" Can someone show me how to code so that when ever i save my form it generates automatically QueueNumber + ...
0
votes
1
answer
217
views
Refresh the data in entity created using database-first approach model in Entity Framework
using (DEMONewEntities demonew = new DEMONewEntities())
{
}
In App.Config we have the following entry :
This is the structure generated in the Solution folder .
I have created the database ...
0
votes
0
answers
72
views
ínvalid column 'ImageUrl' in table asp.netusers
I am working on an API using Entity Framework and i added new models to the template model. when i do a migration, it is successful but when i run an update database from package manager console, it ...
0
votes
1
answer
2k
views
Async task method issue on a linq query return in c#
I need help here with async tasks I am trying to return a list of values coming from a database and I have a table repository and then using a irepository of that class, the issue I am having is using ...
1
vote
1
answer
42
views
I have to store Primary key of 1st table to 2nd table in MVC entity framework DB first. foreign key in MVC
I have tried Tempdata, globally declared and session using MVC with entity framework 6 db first approach
public class CustomerModel
{
//i have to pass or store cusid to paymentModel
public ...
0
votes
2
answers
1k
views
Running multiple select queries using the same db context
Can you run multiple "select" queries using the same data context? Today at work, I ran into a situation where the query returns inaccurate results when I run multiple "select" queries in the same ...
-2
votes
1
answer
546
views
How to compare the data between two models that have the same tables name in Entity Framework?
Assume you have 2 databases scripts (Source & Destination) with the same structure and different data.
This is the source database:
https://drive.google.com/file/d/...
0
votes
0
answers
166
views
How to record/audit changes for Insert/Add C# EF4
Is there a non-complex way of auditing Entity Changes for insert/add?
I use the code below to record Entity changes for Edit/Update
var context = new DBEntities(connection());
try
{
BPCategory Bp ...
1
vote
1
answer
1k
views
How to display certain column from a separate table in WPF DataGrid?
I have a two tables, lets call them T and V.
Table T contains all the data needed to display in the data grid and table V contains data about certain column in table T. So table T contains a foreign ...
0
votes
0
answers
372
views
How to implement Cascade on Delete Using Asp.coreBoilerplate Entity Framework?
I want to implement Cascade on delete functionality for asp.net core boilerplate. But I am unable to do so? Here is what I have done to do this.
Company is the parent Class:
public class Company:...