Questions tagged [entity-framework]

Entity Framework is a LINQ-based object-database mapper for .NET. It supports change tracking, updates, and schema migrations for many databases. Please add a version-specific tag as well.

Entity Framework is .NET's Object-Relational Mapping (ORM) tool that enables .NET developers to work with relational data using domain-specific objects. It eliminates the need for most of the data-access code that developers usually need to write. Either natively, or through third-party libraries, it supports most major RDBM products including SQL Server, MySQL, Oracle, PostgreSQL and SQLite. It also supports Microsoft's "LINQ" syntax and lambda-expressions.

Entity Framework was first developed for .Net framework (production-ready versions 4.x - 6.x). In 2016, Entity Framework for .Net core (EF-core) was introduced, having a completely new codebase which shares many concepts with the classic framework but differs considerably in mapping syntax, query translation and specific features. After version 1 and 2, EF-core 3 came with many breaking changes, marking the beginning of a more stable evolution path. EF core 5 (versions keep track with .Net core versions) has far less breaking changes.

As of version 6.3.0, EF 6 is cross-platform. It targets .Net standard 2.1. NuGet packages are available for .Net core 3 and .NET Framework 4.x.

Because of all these different versions it's very important to use the right tags when asking questions.

Entity Framework is well-documented.

91477 questions
21
votes
5 answers

Is there any reason to make POCOs into Model objects?

If I am generating POCO objects from EntityFramework, and using these to go to/from the WCF server, is there any reason to create client-side Models for the Views & ViewModels to use instead of just using the POCOs directly? Almost all the MVVM…
Rachel
  • 130,264
  • 66
  • 304
  • 490
21
votes
3 answers

DbContextOptionsBuilder.EnableSensitiveDataLogging Doesn't Do Anything

I'm trying to track down the cause of an Entity Framework InvalidOperationException in an ASP.NET Core project. The exception suggests using DbContextOptionsBuilder.EnableSensitiveDataLogging. In my Startup.cs I have: public void…
Simon Morgan
  • 2,018
  • 5
  • 23
  • 36
21
votes
7 answers

SqlException (0x80131904): Invalid object name 'dbo.Categories'

I am getting the exception above when I run an application. The application is using asp.net mvc 3 / C#. I made an mdf file and added it under App_Data folder in Visual Web Developer Express. I added connection strings to the web.config folder but…
user522767
  • 4,013
  • 6
  • 21
  • 17
21
votes
4 answers

Map System.Uri using Entity Framework Fluent Api

Pretty simple question. I have a model that has a property which is a System.Uri type. Uris don't have a default parameterless constructor, and no ID field. Is there any way to override my model generation to store it in the DB in a custom way…
Paul
  • 35,689
  • 11
  • 93
  • 122
21
votes
8 answers

Returning a DataTable using Entity Framework ExecuteStoreQuery

I am working with a system that has many stored procedures that need to be displayed. Creating entities for each of my objects is not practical. Is it possible and how would I return a DataTable using ExecuteStoreQuery ? public…
detroitpro
  • 3,853
  • 4
  • 35
  • 64
21
votes
6 answers

How to sort DataGridView when bound to a binding source that is linked to an EF4 Entity

I have a DataGridView that is linked to a BindingSource. My BindingSource is linked to an IQueryable list of entities: public void BindTo(IQueryable elements) { BindingSource source = new BindingSource(); source.DataSource =…
Martin
  • 39,569
  • 20
  • 99
  • 130
21
votes
5 answers

Error 175: The specified data store provider cannot be found

I'm using VS2010 with the MySQL .NET Connector. My project that used to work started reporting: Error 175: The specified data store provider cannot be found, or is not valid. I don't know why, though things got weird after a MS recommended hotfix…
21
votes
4 answers

Entity Framework Core 2.0 on .NET 4.6.1

Microsoft just announced that Entity Framework Core 2.0 will now run on .NET Standard 2.0. .Net Standard 2.0 is compatible (if that's the right term here) with .NET Framework 4.6.1. However when I try add the latest NuGet package I get an error…
user281921
  • 661
  • 2
  • 8
  • 25
21
votes
3 answers

Force EF 4.1 Code First to See an Attached entity as Modified

All the examples I've found refer to a class called ObjectContext, which doesn't appear to exist in CTP5. I must stress at this point, CTP5 is my first exposure to the Entity Framework. I have a disconnected POCO that I have attached to my…
kim3er
  • 6,306
  • 4
  • 41
  • 69
21
votes
6 answers

Linq2SQL vs EF in .net Framework 4.0

So what's the verdict on these two products now? I can't seem to find anything regarding this issue SPECIFICALLY for VS2010/.net 4.0 Back in .net 3.5 days, most people believe Linq2SQL will be dead when .net 4.0 comes around, but it seems alive and…
21
votes
2 answers

Entity framework core update many to many

We are porting our existing MVC6 EF6 application to Core. Is there a simple method in EF Core to update a many-to-many relationship? My old code from EF6 where we clear the list and overwrite it with the new data no longer works. var model = await…
Talnaci Sergiu Vlad
  • 922
  • 1
  • 10
  • 17
21
votes
2 answers

ef-core load collection property of nested tph inherited member

Given the following class structure public class Parent { public Guid Id { get; public List Children { get; set; } } public abstract class BaseChild { public int Id { get; set; } public…
Elmer Ortega
  • 469
  • 4
  • 12
21
votes
2 answers

Entity framework query on just added but not saved values

I'm using Entity Framework from a couple of years and I have a little problem now. I add an entity to my table, with Entities.dbContext.MyTable.Add(obj1); and here ok. Then, I'd like to make a query on MyTable,…
Piero Alberto
  • 3,823
  • 6
  • 56
  • 108
21
votes
2 answers

Entity Framework stored procedure with multiple resultsets?

I am new to EF4 . I am using a stored procedure that returns 2 resultsets? I understand that this is not possible and not supported.Pity! What is the workaround? any code examples? Thanks a lot
user9969
  • 15,632
  • 39
  • 107
  • 175
21
votes
3 answers

IDbAsyncQueryProvider in EntityFrameworkCore

I'm using XUNIT to test in a dot net core application. I need to test a service that is internally making an async query on a DbSet in my datacontext. I've seen here that mocking that DbSet asynchronously is possible. The problem I'm having is that…
Chris
  • 7,996
  • 11
  • 66
  • 98
1 2 3
99
100