Questions tagged [entity-framework-6]

Do NOT use this tag for Entity Framework Core 6 questions. This tag is for questions about Entity Framework 6, an ORM first released in 2013 and most recently updated to EF6.4 in 2019. It is not the same product as EF Core 6, first released in 2021

Filter by
Sorted by
Tagged with
0 votes
1 answer
51 views

Entity table exists but I cannot access it through Model

I am using C#, .NET 4.6 and EF 6.13 in Visual Studio 2019. I started having issues with a new table I added to the database and then refreshed my model. I then refreshed model. When I went to access ...
ErocM's user avatar
  • 4,505
0 votes
1 answer
58 views

How to Implement SQL Server Always Encrypted with "ErikEJ.EntityFramework.SqlServer" and Azure KeyVault in ASP.NET MVC 5?

I have an existing ASP.NET MVC 5 web application that uses Entity Framework 6 and targets .NET Framework 4.7.2. I want to implement SQL Server Always Encrypted using the "ErikEJ.EntityFramework....
Libin TK's user avatar
  • 1,477
-1 votes
0 answers
34 views

In Entity Framework 6.0, is there a way to delete a row when it's not referenced anywhere else?

I'm completely new to Entity Framework and trying to understand the principles around it and how far I can go with it. Let's say I have 3 tables: Students, Teachers, Addresses Let's say both Students ...
Jean Beaudry's user avatar
0 votes
0 answers
24 views

Linq query brings back an unknown column exception

I'm trying to populate a list of objects from a MySql database using EF6. Unfortunately, it keeps throwing out with the following message: MySqlException: Unknown column 'Extent1.AccountId' in 'where ...
Tim's user avatar
  • 45
0 votes
0 answers
42 views

What is the best way to tune LINQ with pagination and order by? [duplicate]

I have a nullable column in my SQL Server table, let's say SomeDate. My objective is to get the rows where SomeDate is not null, then order by that same column and use pagination. Here are sample rows:...
GThree's user avatar
  • 2,758
2 votes
1 answer
55 views

Wrong Import of a One-To-One relationship

I have this three tables: CREATE TABLE [A] ( [id] INT NOT NULL IDENTITY (1,1), [serial] VARCHAR(255) NOT NULL, PRIMARY KEY([id]) ); CREATE TABLE [B] ( [id] INT NOT NULL IDENTITY (...
th3g3ntl3man's user avatar
  • 1,948
1 vote
1 answer
49 views

Dapper with transactions throws "open DataReader associated with this command which must be closed first"

Very intermittently I am getting InvalidOperationException "open DataReader associated with this command which must be closed first" This is a too long mission critical piece of code that ...
PMC's user avatar
  • 4,710
0 votes
2 answers
44 views

One to One and One to Many Optional Entity Framework

I have a model like this : public class PortStackingDetails { [Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; set; } public int? ...
Jun Rikson's user avatar
  • 1,964
0 votes
0 answers
43 views

Is Count() not supported with EF Core and GroupBy()/GroupJoin()

I have a number of Api endpoints that implement filtering and paging via odata or scim. We currently use EF6 to get the IQueryable by calling a method to project the ModelType to the ResultType. We ...
Brian's user avatar
  • 395
1 vote
1 answer
27 views

Devart to ODP.NET -> ORA-08177: can't serialize access for this transaction

I am a beginner in everything related to connectors, db, etc. My company has a Devart connector for the database and we are trying to upgrade using ODP.NET. When I change everything and try to restart ...
Victor Amell's user avatar
0 votes
0 answers
37 views

Can't seed objects with enum using HasData() and Entity Framework

I have an issue as Entity Framework throws an exception when I want to seed data using HasData(), because object has enum property. The problem started to appear when I switched string Name to enum ...
JakubCzura's user avatar
0 votes
1 answer
47 views

EF6 C# Join Not getting what expected

I have two tables, one is called profiles and the other is called tools. They are joined in a 1-many condition. i.e. a profile can have multiple tools and are joined that tools has a column which has ...
Combinu's user avatar
  • 882
1 vote
0 answers
20 views

RDLC Design Page Can't Connect to context.cs in EF6 vs. EF Core (Different .NET Versions)

I'm using C# .NET 6 I opened two separate projects for this problem: One using .Net Framework 4.8 The other using .Net 6 I tried separately in both projects: In the project using .Net Framework 4.8, I ...
Mert Atmaca's user avatar
3 votes
1 answer
36 views

One-to-one with two independent tables

I have two tables: Indivdiual and Instructor. If an Instructor is an Individaul (that we track), I want to link their Instructor record to their Individual record. An Individual may or not be an ...
Andrew's user avatar
  • 2,013
0 votes
0 answers
36 views

Linq Where -> Any on non-primitive object collections? [duplicate]

So I've noticed that we have a ton of database calls and trying to reduce them to a minimum, but I ran into issues attempting it. How I've normally done it: List<ItemData> itemData = new List<...
Robert's user avatar
  • 1,755
0 votes
0 answers
32 views

Entity Framework EDMX not updating connection string in ASP.NET web application

I'm currently working on an ASP.NET web application that uses Entity Framework for database access. I've encountered an issue where I updated the connection string in my web.config file to point to a ...
PixelScribe's user avatar
1 vote
0 answers
20 views

EF 6, .NET 4.8 : resulting query doesn't seem to use StringLength

I've seen similar questions and have tried applying the answers, but to no avail, so I wanted to ask my question with more context of what I've tried. My property looks like this: [Column("colnm&...
Jason Jacobs's user avatar
0 votes
0 answers
21 views

Saving changes of only the nested transaction in Entity Framework

I have code that builds data into object A. There is a transaction for doing that. While collecting data, I need to insert object B into the database and use its ID for A. There are many levels of ...
JHM's user avatar
  • 391
0 votes
0 answers
22 views

The first of the id's in the table created while seeding is null

I am using Entity Framework 6, and when I try seeding some data the GuideId and DriverID returns null. I am not sure it is related or not but I am trying to create a entity called Tour and it has two ...
Fettah Basdemir's user avatar
0 votes
0 answers
16 views

How to add constraint to entity framework model builder [duplicate]

I am trying to add the following constraint in entity framework model builder, ALTER TABLE [dbo].[Portfolio] ADD CONSTRAINT [uc_Portfolio_idx1] UNIQUE NONCLUSTERED ( [Id] ASC )WITH (...
Garry A's user avatar
  • 393
0 votes
0 answers
66 views

Save large Binary data into LONG RAW data type using .Net Entity Framework 6.4

We have a legacy oracle table where all documents are stored in binary data format using the LONG RAW data type. As a part of system upgradation, we need to insert binary data into the same LONG RAW ...
Enthusiastic's user avatar
0 votes
0 answers
18 views

Entity Framework 6, Fluent API - many-to-many relationship

I am using EF 6.4.4 in an ASP.NET MVC 4 application and am trying to model some SQL using Fluent API a many-to-many relationship with a join table. The SQL I am trying to duplicate is as follows: ...
AndyW's user avatar
  • 303
0 votes
0 answers
12 views

How to Use Oracle Database in Entity Data Model

I am able to add Oracle database in Data Source -> Server Explorer, The problem is, when I use ADO.NET Entity Data Model extension, I dont see Oracle Database option. Do I need to install ...
Keval Patel's user avatar
0 votes
0 answers
34 views

Additional column TempId3 is cretated on migration in Entity Framework 6

I have public abstract class DocumentBaseModel { public int Id { get; set; } } public class SaleCompileDocument : DocumentBaseModel { public ICollection<EmailNotification> ...
dm k's user avatar
  • 111
0 votes
1 answer
21 views

Using EntityFramework6 to store a list of subclasses

Using EntityFramework6, I wish to store a list of subclasses in a MS SqlServer. Perhaps best explained with example. What are my options? Can I store Children in a single table with {ClassType NOT ...
Anders Juul's user avatar
  • 2,419
0 votes
0 answers
89 views

Unable to enable Entity Framework migrations in .NET 4.8 ASP.NET Webforms project

I'm currently working on a home assignment where I am tasked with creating a cargo tracking application using ASP.NET Webforms and the .NET Framework 4.8. For database management, I've opted for the ...
Kadir Mamak's user avatar
0 votes
1 answer
33 views

I have an error when I try to connect to PostgreSQL from Entity Framework

I have the following error: System.InvalidOperationException: 'The Entity Framework provider type 'Npgsql.NpgsqlServices,Npgsql.EntityFramework' registered in the application config file for the ADO....
gabrielfsx's user avatar
0 votes
0 answers
18 views

EF6 produces exception 'Invalid object name 'dbo.__MigrationHistory'

I'm developing a complex solution where I use Entity Framework 6 for my data layer operations. So far everything works as expected. But at startup of my application I get a strange exception, which ...
Merlin May's user avatar
0 votes
0 answers
19 views

Own DbConfiguration for each DbContext - EntityFramework 6

I have two projects with their own DbContext. One references the other so I can use both databases. I want to load a seperate DbConfiguration for each DbContext but I am getting the following error: ...
Tommehh's user avatar
  • 872
0 votes
0 answers
32 views

SQLite not an option using Generate Database Wizard with Entity Framework 6

I am attempting to change the database provider for a project that uses Entity Framework 6.4.4 from SQL Server to SQLite. I have the SQLite nuget package installed on the project as well as the SQLite ...
acs676's user avatar
  • 1
1 vote
1 answer
61 views

How to reuse lambda expression on entities with different property names in EF Core with MS Data Sync?

In ASP.Net EF Core I have various entity models with corresponding controllers which inherit from Microsoft.AspNetCore.DataSync.TableController and each model inherits EntityTableData from the same ...
RyanO's user avatar
  • 21
1 vote
0 answers
17 views

Calling Event Handler and using DBContext inside throws "disposed context" exception [duplicate]

I have a Service that handles a file upload. After the upload is finished, I'm raising the upload complete event. Inside the event, I want to set the "upload finished" state and write the &...
mimimi's user avatar
  • 33
0 votes
0 answers
40 views

Cannot insert the value NULL into column '', table 'Orders'; column does not allow nulls. UPDATE fails

Every time I run update-database, this error is thrown. I have tried to add computed annotations to the datetime properties, but that did not work. Here is my class: public class Order { [Key] ...
itsReinsy's user avatar
1 vote
1 answer
22 views

Unit Testing DbContext For Entities Having List<string> Properties

I have entities in my DbContext which contain properties of type List<string>, which is a valid way to store data in Postgres as text[]. Tags = table.Column<List<string>>(type: "...
hunter's user avatar
  • 62.3k
0 votes
1 answer
69 views

How edit EDMX file (EF6) on .NET 7.0

I am volunteer in a one project. We develop ASP.NET MVC Core app and we updated project to .NET 7.0. From this moment app works fine all the time, but I can't view edmx file. Is a way edit edmx ...
SMKI's user avatar
  • 1
0 votes
1 answer
42 views

Why is EF one-to-one relationship deleting the parent upon adding of child?

I have been working with Entity Framework for a while now using only one-to-many relationships with a code-first approach. However, I have now reached a point where I want to implement a one-to-zero/...
Pile's user avatar
  • 15
0 votes
0 answers
35 views

Entity Framework 6 Ignoring Distinct in SQL Query when Selecting Multiple Columns

I am not seeing the expected sql generated for Linq to SQL with regard to Distinct when selecting multiple columns. In particular the Distinct is being left out of the generated SQL. Strangely, this ...
Eric's user avatar
  • 2,140
0 votes
0 answers
36 views

Sum hours in a select [duplicate]

I want to Sum the TotalMinutes of my Activity Table grouped by all the persons. var activitieIds = new List<int>{ 1, 2, 3, 4, 5 }; var spendHours = await _context.Activities .Where(...
visCode's user avatar
  • 145
0 votes
1 answer
57 views

Entity Framework Add() to ORACLE DB raises INSERT operation disallowed on virtual columns [closed]

I have Oracle DB that has multiple Tables (Three of them have ID Column with ALWAYS GENERATED IDENTITY) that is required to be connected to Windows Form. BREAKDOWN Table CREATE TABLE "BREAKDOWN&...
Mohamed Reyad's user avatar
0 votes
0 answers
27 views

SELECT on full model fails because some columns are created in a later migration

I'm using Entity Framework 6 with SQLite and https://www.nuget.org/packages/System.Data.SQLite.EF6.Migrations. AutomaticMigrationsEnabled is disabled. In update-method I call Migrator.Update(...
Christopher's user avatar
0 votes
1 answer
40 views

jsonserializationexception: self referencing loop detected for property

I'm using C# asp.net core ef6 linq mssql VS2022 when I build the project I can see this page I checked these pages... 2 3 the 2's JsonIgnore was worked but I have problem. I using ef core power tools ...
nyny's user avatar
  • 23
1 vote
2 answers
73 views

Handling DbUpdateConcurrencyException by simply aborting all operations

I'm new to the EF 6 and i'm trying to implement optimistic concurrency control , simply by alerting the user of the conflict and aborting all operations, i'm not interested in analysing the conflict, ...
xProgrammerx's user avatar
0 votes
0 answers
18 views

Entity Framework 7 One to Many Mapping on non-key columns

I am trying to use fluent API to map a relationship. I am not even sure this is possible, but here is what I am attempting. I simplified this from the actual business case. So in this version, we have ...
Frank's user avatar
  • 13
0 votes
2 answers
31 views

How to append multiple column using Select based on condition in Entity Framework?

I want to select the multiple column based on if condition, While adding "Select" method as nested it is not working, Getting null for each properties in the class. So how to fix this? ...
Natheeshkumar Rangasamy's user avatar
0 votes
3 answers
56 views

How to do a LINQ-SQL query on a delimited column, without resorting to client-side evaluation

I am trying to query a view, which has an "Operator" column. Sample data: Ed Edward Ed;Adam [null] Bob; Edward Bob; Ed; Tom Given a user input of a List<string>, let's say "Ed&...
pkExec's user avatar
  • 1,819
0 votes
1 answer
536 views

ASP.NET Core 7 MVC, EF Core, SQL Server : DbContext connection issue upgrade from .NET 4.8 EF6

I am having problems with a SQL Server connection while upgrading an ASP.NET 4.8 MVC application to an ASP.NET Core 7 MVC application. When a controller references the MainDbContext, it's value is ...
Beengie's user avatar
  • 1,588
0 votes
1 answer
34 views

Insert a List of complex objects without inserting navigational properties in Entity Framework

Given the following model classes: Public class User { public int UserId { get; set; } public string Name { get; set; } public List<Rule> Rules { get; set; } } public class Rule { ...
lacoder's user avatar
  • 1,253
0 votes
0 answers
67 views

SQL-Deadlock using EF 6

I have an import routine, that imports a lot of data from my ERP into my SQL-Database. I'm importing the data in batches of 20. The imported IDs coming from my ERP are compared with the ones from my ...
Tibso's user avatar
  • 1
2 votes
1 answer
39 views

Entity Framework Core - SQL Update Cache Plan Issue

I have a simple application that listen to events from service bus. Based on incoming events, it will update records in the database using Entity Framework Core. The application will batch incoming ...
Henri's user avatar
  • 69
0 votes
0 answers
61 views

Error trying to save changes when property is also part of the foreign key using Entity Framework 6

I have a table [dbo].[Feature] public class Feature { public Guid Id { get; set; } public string Name { get; set; } = string.Empty; public ICollection<FeatureProperty> ...
carlosm's user avatar
  • 695

1
2 3 4 5
220