Questions tagged [entity-framework]

For questions about the ADO.NET Entity Framework, the Object-Relational-Mapping (ORM) tools for the .NET Framework. Please add a version specific tag, when applicable. Do NOT use this tag for Entity-Framework-core questions. Use entity-framework-core instead.

0
votes
0answers
22 views

How to insert data in to two tables based on parameters

I have two Entities public class ProductOption { [Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int OptionId { get; set; } [Required] [...
0
votes
0answers
17 views

Ambiguity between 'Startup.Configuration' and 'Startup.Configuration'

I get an error of "Ambiguity between 'Startup.Configuration' and 'Startup.Configuration'" on my startup class. I don't know what I have done to cause this issue. All I did was create a DBContext class ...
0
votes
1answer
34 views

Using Entity Framework, how to create a query which will fetch the column names of all tables from a database

How to create a dynamic select query in C# using Entity Framework which will fetch all the column names from a SQL database. Here, the table names to be supplied in the query are fetched from a ...
0
votes
2answers
20 views

EF Table with inheritace but not Abstract?

I want to make three table: Tasks - that table store informations as Ids, Names, Priority of tasks TakenTasks - in this table we store user's ID that take tasks with DateTime EndedTasks - Task that ...
0
votes
0answers
16 views

Handle read and write concurrency of Entity Framework in multi instance deployment (in cloud)

In a recent project, in which, we are using EF6 (in an ASP.Net MVC web app) and deploying the solution to a 12 instance cloud service we are facing with some serious concurrency issues. Even though ...
0
votes
1answer
15 views

Trouble with the ModelState.IsValid returning false

In ASP.NET using Entity Framework I'm trying to add a new entry to a database named Provider. The view returns a default value UserID and a category as a foreign key from another table. When I debug ...
0
votes
1answer
26 views

How to bind two source of data into a datagrid in c#

my problem is the following : I have a datagrid of "salesTable" using entity framework, I load the datagrid with this code : salesDataGrid.ItemsSource = _db.salesTables.ToList(); one of the ...
0
votes
0answers
24 views

Raw SQL script to get many-to-one objects in Entity Framework

I'm using Entity Framework Core with C# and SQL Server to run some user provided raw SQL queries, and I need to find a SQL script that will return a list of objects with a many-to-one relationship. ...
0
votes
1answer
43 views

Linq query returns unwanted results as well

I'm new to linq and C#, trying to query complex objects by a certain property. The scenario is I have a list of currentPerson objects, which include PersonAddressesDisplay property, which is a string. ...
0
votes
0answers
13 views

Listing of data in many to many table relations using .net mvc 5

I am student developper in Asp.Net MVC. I am doing small .Net MVC projects for learning it own my own and I am facing many to many relation between tables for first time. I have two model which have ...
1
vote
0answers
31 views

Is there any way to change value of field set to “StoreGeneratedPattern=Computed”

I have an int field in my table set to default 0. I set this field's StoreGeneratedPattern as Computed, but I can't change the value of this field after using SaveChanges(). I have found this answer ...
1
vote
1answer
35 views

How to transfer SQL data from one table to another using Entity Framework Core

I have two tables in my database that contain the same columns. TBL one and TBL two which is history table. When I am entering data into TBL 1, I want to move all data from TBL 1 to Tbl 2 (as history ...
0
votes
2answers
69 views

EF core DbContext in a multithreaded API application

tl;dr How can I use Entity Framework in a multithreaded .NET Core API application even though DbContext is not threadsafe? Context I am working on a .NET Core API app exposing several RESTful ...
0
votes
0answers
28 views

'There is no ViewData item of type 'IEnumerable<SelectListItem>' that has the key 'IsWorkingID

I am creating an ASP.NET MVC registration form and I use dropdown list in my form, but when I hit the submit button in my view, this error occurs: System.InvalidOperationException: 'There is no ...
1
vote
1answer
35 views

How to retrieve ID generated by DB after saveChanges using DbContextScope

I plan to create an application having the following layers, and use Entity Framework as my ORM: Presentation: not relevant for my question. Business: in this layer I plan to only use DTO objects. I ...
0
votes
0answers
19 views

how to re-execute the generated query from EF's output

I am new to Entity Framework. When I review the T-query generated by Entity Framework, it shows a comment-out line for parameter with assigned type and value information, eg. -- p__linq__0: 'ABC' (...
0
votes
1answer
13 views

One-to-one relationship does not carry both classes

I'm using the Entity Framework to persist and retrieve some information, I have a one-to-one relationship. Product and Category, where a Product has a Category and a Category may have several Products....
0
votes
0answers
31 views

Second request is waiting for the first response

I am using MVC with SQL Server as DB and Jquery. Now when I just load a web page that should fetch the information from DB (Taking 3 - 4 seconds), the complete page from browser is waiting for the ...
0
votes
0answers
19 views

How to Get last working page in my application while log in

i have use angular 6 as a front end and .net web api as a back end. In my application 4 pop(Merged) is there.if user log in the application open the second pop up then close the browser window or log ...
1
vote
2answers
52 views

How to display two tables separately in a single view with a join query in one table?

I am creating a dashboard in ASP.NET MVC using C# and Entity Framework. I have two tables Tbl_Channel (Id, Channel_Name) Tbl_News (Id, Channel_Id, News_Title, News_Description) When I tried this ...
2
votes
1answer
35 views

What would be the consequences if I disable the ProxyCreation globally in Entity Framework?

The Entity Framework uses proxy classes for some of its internal stuff, as seen in this question we have to disable it, because it cause issues with the serialization of the objects. My question is ...
0
votes
1answer
12 views

Entity Framework 6 A dependent property in a ReferentialConstraint is mapped to a store-generated column. Error

I have 2 entities configured using Entity Framework 6. Both entities have Identity on for generating primary keys on insert. When i try adding new customer I get following error. A dependent ...
0
votes
0answers
26 views

Trying to edit a user throws tracking exception

I am playing around with ASP NET Core and EF. I have created a User class which inherits IDentityUser and adds some fields, such as first name, last name and so on. Furthermore, I have other types of ...
1
vote
0answers
36 views

Edit profile information directly from profile screen MVC c#

I am building a Model-View-Controller entity framework website in c#. I have a profile page that displays the user information. I want the user to be able to edit their profile information without ...
1
vote
2answers
77 views

Looping over large quantity of data in a list of list of strings crash visual studio c#

I'm implementing a functionality for a web page that will upload large amount of data (3x10^5 rows aprox.) to different tables in a database at the same time. The user will generate an excel file ...
-1
votes
0answers
37 views

Issue with .NET LINQ query preparation

We are having an issue in linq query. In select query multiple tables are associated with joins. Where record filters were applied on join section. This query was running fine and giving proper ...
1
vote
1answer
19 views

CheckBox Column in DatagridView built on linq to Entities query

I have a DataGridView built on linq to entities. I used Entity Framework to build the Model on a database view. One column is a bool type but the DataGridView gives me the text 'true' or 'false'. I ...
1
vote
1answer
35 views

pass array from javacript to viewbag and use it in controller

my school project is about building an app for employees of airplane company. we decided to combine identity for log in, and our tables with data required by the project. we modified the registration ...
-1
votes
2answers
26 views

c# , How to call Calculate Age and call method in Linq , windows form

I get this error message when I load all employees when I load employees in dataGridView form. "LINQ to Entities Does Not Recognize the Method 'int32 CalculateAge(Int32)' method, and this methode ...
0
votes
0answers
21 views

How to fix random “The wait operation timed out” with EF 6 and SQL Server AWS RDS

PROBLEM: Since a DB migration, I have many intermittent exception from SQL timeout. All what I now after my 2 months of investigation: All my .NET C# apps using RF 6 are impacted Whatever time in ...
0
votes
0answers
35 views

Manual Migration with EF6

I had to refactor an existing database, where I manually modified the primary keys and added foreign keys. In the production database I did this manually using the SQL designer, then I created the ...
0
votes
1answer
38 views

.Include() affects query's number of results

I have very simple query which returns Order, but when I perform the same query with many Includes and ThenInclude then query returns 0 results instead of 1 var a = _context .Orders ....
0
votes
1answer
13 views

EF6 Schema compare between dataase and sql-file?

I use EF6 model-first approach to design MS SQL database by using "Generate database from model..." in Visual Studio. This generates a sql-file with all drop and create statements. At some productive ...
1
vote
1answer
28 views

Order columns in migrations EF Core

'I'm working on an EF Core application where I inherit a common class in an entity. When I migrate and update the database, the inherited columns get created in the first place and the properties of ...
0
votes
0answers
16 views

How Can I access Oracle Procedure Using Oracle.ManagedDataAccess.EntityFramework?

How can I access an Oracle procedure using Oracle.ManagedDataAccess.EntityFramework ? I have 2 tables in Oracle 11g database: COURSES and AUTHORS. I have created a simple procedure like this: create ...
0
votes
0answers
30 views

WCF Seralization issue with EF

I am getting this weird exception in WCF Service Exception thrown: 'System.Runtime.Serialization.SerializationException' in System.Runtime.Serialization.dll Here is the given schema of the DB: Here ...
0
votes
1answer
16 views

asp.net code first many to many with the same table

To make the M: M relation work must: {In Remove Class I should set the IDs(TL_Id, JD_ID, PM_ID) as Users Class ID name (UserId) to work, and so on with object Users names(TL, JD, PM)}. Is there any ...
0
votes
1answer
37 views

EF Core - conditional relationship - vertical table splitting

I've to deal with a special relationship, due to an existing database schema. The db: - table Cat (id, name) - table Dog (id, name) - view Animals: SELECT 'C' + CAST(Id AS VARCHAR) AS AnimalId, Id AS ...
0
votes
0answers
29 views

How to get the original values from a navigation collection property in Entity Framework Core?

With Entity Framework Core, I need to check the original values of a navigation property inside my entity but i can't find a way to do it. I'm able to read the original and the current values of the ...
-1
votes
1answer
34 views

Iterating through async task to update user role

I am writing an Edit method for my C.R.U.D application but I am stuck with updating user role. I am trying to iterate through user roles and assign user role is not already assigned role. I get an ...
0
votes
2answers
42 views

Retrieving a list from a database query with Entity Framework 6

I want to return a list with entity framework using (FinalDatabaseEntities fdb = new FinalDatabaseEntities()) { var result = from Port in fdb.Ports select Port.Name; result = result.ToList(); ...
0
votes
0answers
11 views

How to map raw query search to a model with child object?

Is there a way to map results from a raw sql query using Entity Framework such as var results = await context.Database.SqlQuery<TestModel>(sql, parameters.ToArray()).ToListAsync(); with query ...
0
votes
1answer
18 views

Automapper “Error mapping types” error when joining ICollection table

In an Angular project based on ASP.NET MVC and EF, I have the following entities as shown below: Note: There is no error if I don't add a file attachment. But adding a file causing this error during ...
0
votes
1answer
36 views

Connection string for Entity Framework in an Azure Function

I'm creating an Azure Function and I've added a reference to a project that uses Entity Framework. I've copied the connection string from that project and pasted in the local.settings.json file inside ...
0
votes
1answer
42 views

Convert IQueryable<ExposedClass> to IQueryable<InternalClass>

I'm trying to convert IQueryalbe<ExposedClass> to IQueryable<InternalClass> so that my business layer doesn't get impacted directly when changes might to my .edmx file but keep it being ...
0
votes
1answer
26 views

AddDbContext not working in ConfigureServices of ASP.NET Razor 2.2

I reversed a sql server database into their respective classes and context, and all this appears to of worked fine. In the min context class, there is a line of code pointing to the connection string,...
0
votes
0answers
33 views

Correct way to configure ASP.NET Identity one to one relationship with different types of users?

I have a simple scenario in which I am developing an application that will encompass different users. It's basically a Classroom Management application. So, I have different roles that will see the ...
0
votes
2answers
33 views

how insert same record in multiple times using entity framework

How to insert same record in multiple times without using for loop because its taking to much time I want to insert 10lack record at a time for (int i = 0; i < 1000; i++) ...
1
vote
1answer
32 views

EntityFramework, getting Object ID while added to table

I have a question. Im adding object to my table in this way: this.db.Objects.Add(new Object { Text ="someText", Number = number }); Then, i want to add second object to another table that is ...
3
votes
1answer
48 views

Visual Studio 2019 .EDMX Update Model From Database Does not work

@ajcvickers I am also facing the same issue.. My web project was created in VS 2015 then after 1 years I start the development on 2017 and just few days back we jumped to 2019 but seems like the same ...

http://mssss.yulina-kosm.ru