Join us in building a kind, collaborative learning community via our updated Code of Conduct.

Questions tagged [entity-framework]

For questions about the ADO.NET Entity Framework, the Object-Relational-Mapping (ORM) tools for the .NET Framework. Add a version specific tag as well, when applicable.

0
votes
2answers
20 views

Auto increment PK starting from zero - EF Core code-first

I'm using ASP.NET Core and EF Core with code-first approach. Database is MSSQL. Is it posible to increment Id primary key starting at 0?
0
votes
0answers
22 views

Calculated column in view performance issue

I've got a table with location data (Lat/Lngs) stored as geography type. Now this location data represents a Journey, so I want to calculate the distance travelled during the Journey, distance per ...
-1
votes
1answer
12 views

save async with EF in foreach

I want to save my object by iterating in a Foreach loop, and return the result to my controller Here is the controller code: public async Task<HttpResponseMessage> PostSubmissionFirm(JArray ...
-1
votes
0answers
23 views

Filter some records coming from database to use as dropdown textbox in Entity Framework

I am making Hospital management system project in ASP.NET MVC using Entity Framework with a database-first approach. I have two tables in database i.e. rooms and room_allotment. Rooms table has a ...
0
votes
1answer
24 views

Entity Framework select many-to-many with concat text

clases Book: Id, Name, Content, Publishment Author: Id,Name is many-to-many Book Id | Name | Content | Publishment 1 book1 somecontent some pub 2 book2 ...
0
votes
0answers
38 views

Two foreign keys in a model referencing the same table

It seems I have a problem if I have two properties in a model that reference another table as foreign keys. The engine assigns unexpectedly weird column names to them and as a result I get an SQL ...
2
votes
3answers
60 views

How to aggregate millions of rows using EF Core

I'm trying to aggregate approximately two million rows based on user. One user has several Transactions, each Transaction has a Platform and a TransactionType.I aggregate Platform and TransactionType ...
-3
votes
0answers
21 views

How to write Angular JS delete confirmation with ASP.net MVC

I need to develop ASP.net MVC simple web application with Angular JS. I need to delete table data when clicking the button. This is simple MVC crud application delete code with EF. public ...
0
votes
0answers
13 views

Entity Framework with Web Api 2 - Performance issue

First of all, I want to say that I’m a beginner in .NET and I'm a beginner in english. :( I have the following code in my controller: The intention is to send the data set to the clients. I need to ...
0
votes
1answer
17 views

Creating Azure Hybrid Connection with Hybrid Connection Managaer

I have some REST APIs deployed to an app service an Azure. I have added a hybrid connection to the app service, and deployed the hybrid connection manager to the relay server which I verified can ...
-2
votes
2answers
28 views

ASP.NET Core, Entity Framework - Word document

I've got a project using ASP.NET Core I'm using multi page web application (template found here https://aspnetboilerplate.com/Templates). It's all working fine which ask user to enter info and save to ...
3
votes
0answers
52 views

Manipulating Linq Expressions because I want them to be magic

I have been carving out a section of code for a reporting app. I have derived many interfaces, for example public interface IDateRangeSearchable { DateTime StartDate { get; } DateTime ...
0
votes
0answers
11 views

summarizing duplicate line items in shopping cart with MVC/EF

I am currently working on creating a simple shopping cart where line items are being displayed based on a call to a table. Primarily I am taking advantage of basic CRUD here, so I am reading a table, ...
0
votes
0answers
37 views

DataTable to SQL Server tables with Entity Framework

I have a dataset with several tables and relations in the dataset. I would like to be able to use entity framework to then translate my dataset tables into an SQL server set of tables. I see articles ...
0
votes
1answer
38 views

How to handle limitation of in-memory entities to Unit Test class/service which is using EF 6

I going to unit test a service which is using Entity Framework 6. Sample scenario, it would have Blog and Post entity, Blog having zero or more Posts. In the service method it would return list of ...
2
votes
3answers
63 views

Check which messages already exist without loading entire table to memory

I want to check if any message already exists before adding it to database, but my current query loads the entire table into memory. Query generated from my code is basically just select * from ...
0
votes
0answers
16 views

Entity Framework error “one entity of type have the same primary key ”

As the title said, I've catching the error "saving or accepting changes failed because more than one entity of type have the same primary key value sql trigger" after executing the save changes on ...
0
votes
1answer
28 views

Mysql Entity framework exception

.Net Framework : 4.7.2 MySql server installed: 8.0.12 MySql connector/Net : 8.0.12 Entity Framework: 6.2.0 MySql.Data : 8.0.12 MySql.Data.EntityFramework: 8.0.12 Web.config configuration <...
-6
votes
2answers
49 views

Check if a date is in between collection of Date Periods [on hold]

I'm trying to find if a given date falls between a collection of periods I have a period class with start and end dates, and a date to check if it is in the collection of periods. Here is the sample ...
2
votes
2answers
58 views

LINQ: latest sum of data within data range

I have a snapshot table in my database that holds historical data of appointment availability. I'm trying to write a LINQ query to get the total number of AvailableSlots within a given date range ...
0
votes
1answer
23 views

How to map SQL database results to a domain model in EF Core

I have the following domain models: public class Country { public string ISOAlpha3Code { get; set; } public string NameUS { get; set; } public string NameES { get; set; } public ...
0
votes
1answer
13 views

Setup Error - There is already an object named 'AbpAuditLogs' in the database

I continue to get the same error regardless of which solution I download (pre-release or stable). Here are the steps I follow. Open in Visual Studio Community 2017 v 15.5.3 Build to restore NuGet ...
0
votes
1answer
17 views

Is exists level 2 cache for Entity Framework 6+ not updating whole entity?

All level 2 cache libraries i found clears entity (invalidate entity) in cache when updating / deleting.Then when i call some view that use entity, it call DB for whole table. So, is there a cache ...
0
votes
2answers
28 views

Table has primary key as two foreign keys throws exception when insert the same value for two foreign key in Entity Framework Code First

I have three tables: tbl.Attribute: int Id int AttributeName tbl.Product: public int Id public string tbl.ProductAttribute: int ProductId int AttributeId string Value When I ...
0
votes
0answers
31 views

Stuck on what I'm doing wrong here [duplicate]

I created 3 tables in a database and i have created model classes for each one. In addition to a dbcontext derived class and the program file with method main. I get NullReferenceException, when i try ...
0
votes
0answers
15 views

Inspecting the state of an object in the debuggee of type System.Reflection.MethodBase is not supported in this context

I don't know what this error means. I, am using visual studio for mac 7.5.0 community version. Since I, am using lazy loading in entity framework with asp.net core. public partial class AdminUser { ...
-2
votes
0answers
8 views

Entity Framework Update-database: A network-related or instance-specific error occurred while establishing a connection to SQL Server

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that ...
0
votes
0answers
8 views

Can't read MetadataWorkspace for Context which maps to DbView?

I'm trying to read Mappings from another project, by loading the Assemblies, instantiating the Context Types and getting their MetadataWorkspace through the IObjectContextAdapter.ObjectContext . My ...
0
votes
1answer
34 views

How can I get an one to one object without with only one related entities?

I have a Book class that contains an InventoryItem and the InventoryItem contains the Book, so the relationship is One to One. If I want to get the Inventory item it will return the Book that contains ...
1
vote
1answer
37 views

Returning SQL in text to model in Entity Framework

I have the parents class and the state class: [Table("tb_pais")] public class PaisModel { [Key] [Column("id")] public int Id { get; set; } [Column("nome")] [...
0
votes
0answers
11 views

The entity type IdentityRole is not part of the model for the current context after extending Roles table

I have extended my AspNetRoles that was created by Entity Framework to look like this: public class AspNetRoles:IdentityRole { public AspNetRoles() : base() { } public String Label { ...
0
votes
0answers
19 views

EF Core tracking entities with same id multiple times

I simply want to update an industry property of a client object. To do so, I retrieve the client from the DB using a repository. This would result in my industry (example id:149) being tracked. ...
2
votes
1answer
39 views

Join by LINQ to Entities (EF) same Table based on Time

I have table containing information about time and some data. Expected result is to have the interval (in seconds) between two rows with data shown. MyTable (origin): ------------------------------ |...
0
votes
2answers
37 views

Stuck at reloading related entities for new change from outside?

The scenario here is for each screen (view) there is one ViewModel behind. And for best (or recommended) practice, we should use one long-alive DbContext for each ViewModel. So there is one ...
0
votes
0answers
12 views

Entity Framework, no tt file but want to change ICollection

Having discovered that I can, by hand, create a db table and a corresponding class, a context etc and all 'just works' without any VS EF wizardry whatsoever, this is how I have been using EF for some ...
0
votes
0answers
17 views

Ef Core linq expression

He LINQ expression where (((([x].IsDeleted == False) AndAlso ([x].IsActive == True)) AndAlso ([x].NextInvoiceDate < Convert(DateTime.UtcNow, Nullable`1))) OrElse ([x].ScheduleEndDate > Convert(...
0
votes
2answers
29 views

AspNetRoles table not showing custom fields

I have recently extended my AspNetRoles table like this: public class AspNetRoles:IdentityRole { public AspNetRoles() : base() { } public String Label { get; set; } public ...
-1
votes
2answers
39 views

Linq - In memory join vs EF Join

Using EF 6 and SQL 2014. Assuming you have a well indexed and normalized DB. Is it 'better' to pull entities into memory then perform the join on the IEnumerables or let EF do join via IQueryable? ...
-1
votes
1answer
17 views

What is a efpt.config.json file and should it be checked into source control?

I am using Visual Studio and EF Core Power Tools to reverse engineer some models from my database. This creates a efpt.config.json in my directory and I am wondering whether or not this is something ...
1
vote
2answers
73 views

How often do I need to save the context?

In a repository, I am doing these two consecutive tasks: // Update vendorOrder vendorOrder.VendorOrderStatus = VendorOrderStatus.Completed; vendorOrderRepository.UpdateVendorOrder(vendorOrder); ...
0
votes
2answers
32 views

WPF - How to automatically update ComboBox items after Entity Framework DbContext saveChanges()?

So right now, I have a table with columns EmployeeID, EmployeeName. I also have a ComboBox in my WPF application that displays the EmployeeName. I used the Entity Framework's Code First From Database ...
0
votes
1answer
31 views

Xamarin iOS: Value cannot be null. Parameter name: key

I have a xamarin forms solution, where I have everything working, except for physical iOS devices. It works 100% on emulated iOS, Android, and physical Android devices, but not physical iOS devices. ...
1
vote
1answer
81 views

The server doesn't send data to SQL Server database

I have a strange problem using ASP.Net WebAPI 2, LINQ and Entity Framework. When I send a set of data from front-end to back-end, I saw my data in my ViewModel and data mapped to entity correctly. ...
0
votes
0answers
23 views

Seed method failing at assigning role to user

I'm trying to seed my database but I am getting this error when its time to assign a role to a user Role SystemAdministrator does not exist. I have an additional field in the AspNetRoles table called ...
1
vote
2answers
47 views

EF DateTime formating

I am using EF 6 code first and need to do a sql like on a dateTime in a specific format, IE something along the lines of: my first attempt was something along the lines off: var users = context.User ...
0
votes
1answer
53 views

linq query dynamically inside where

I would like to change dynamically a specific part of the query - depending on the result of if condition. I would be glad for your help: if (someCondition == true) var ADDITION_FILTER_CRITERIA = ...
0
votes
1answer
49 views

How to add/update/delete n-n tables?

I've this tables on my SQL Server Database: On my ASP.NET MVC app I manage the Clinics for each Medical. So let say Medical ID 1 can have N associated Clinics, such as Clinic ID 5, 8, 10. Here's my ...
0
votes
1answer
31 views

Will holding a reference to a string-property of an Entity Framework object keep it from being collected by the GC?

I load entries from my MySQL database with entity framework, and create a new object where I send in the string-properties from the database-object into my constructor and return the new object (with ...
0
votes
0answers
44 views

Entity Framework 6 DateTime.ToString().Contains() Error [duplicate]

Hoping someone can help me out. I have the EF query below which throws an exception, can anyone recommend a different approach. I have seen lots of examples where the solution is to call .ToList() ...
0
votes
0answers
39 views

Creating AX order through a REST API

If a side company have Microsoft Dynamics AX service running (in which they can create orders, import orders from files and etc.) and now we want to be able to get orders through a REST API from other ...