91,797 questions
Tooling
0
votes
4
replies
55
views
Is there a Database First approach in Java like Entity Framework in C#?
I’m used to working with a Database First approach in C#. I design my database schema (often with MySQL Workbench) and do a forward engineering, then generate my C# models using Entity Framework’s. ...
Advice
0
votes
3
replies
44
views
How to set the value in the basic many-to-many relationship example of EF?
Here's a basic example from the official .NET documentation for a many-to-many relationship using EF and .NET:
public class Post
{
public int Id { get; set; }
public List<Tag> Tags { get;...
1
vote
1
answer
101
views
How would I use N.EntityFramework.Extensions to insert into another table
I am trying to use the InsertFromQuery() to add data to a SQL table:
await cx.Users
.Where(x => x.Country == "Romania")
.InsertFromQueryAsync("Mailbox", mb => ...
0
votes
1
answer
149
views
SQL query produced by Entity Framework very slow
I have the following query being generated by EF:
DECLARE @__term_0 VARCHAR(7) = 'woodrow'
DECLARE @__p_1 INT = 0
DECLARE @__p_2 INT = 15
SELECT [t].[Id], [t].[City], [t].[Contact], [t].[CreatedBy], [...
1
vote
2
answers
129
views
C# Entity Framework use value from joined object and only return main object
I am trying to populate a object with additional data from another object with Entity Framework from our data tables.
public partial class Maintable
{
public int Id { get; set; }
public int ...
6
votes
0
answers
134
views
How to manage Entity Framework migrations and databases when using Git version control?
We are planning to use a Gitflow workflow and a shared test database. We currently use EF 6.5.1 and have automatic migrations disabled.
Problem: if a developer runs Update-Database (or dotnet ef ...
1
vote
0
answers
66
views
Mysql ConnectionAttempts increased on AWS RDS after dotnet 6 update to 8
After updating our Dotnet API from dotnet 6 to 8 the connection-attemps on AWS RDS increased significantly (see attached picture).
The API is running in a docker-container.
We use a MYSQL RDS instance ...
734
votes
47
answers
569k
views
MetadataException: Unable to load the specified metadata resource
All of a sudden I keep getting a MetadataException on instantiating my generated ObjectContext class. The connection string in App.Config looks correct - hasn't changed since last it worked - and I've ...
834
votes
27
answers
589k
views
How do I view the SQL generated by the Entity Framework?
How do I view the SQL generated by entity framework ?
(In my particular case I'm using the mysql provider - if it matters)
0
votes
1
answer
94
views
EF Core, Work locally, save/update entire tree of data
I have a TaskFlowTemplate, pretty standard but a bit complex. Our users will have the ability to work locally in memory without need to save after every changes. My primary key is int Id.
public class ...
457
votes
34
answers
321k
views
Entity Framework Provider type could not be loaded?
I am trying to run my tests on TeamCity which is currently installed on my machine.
System.InvalidOperationException:
The Entity Framework provider type
'System.Data.Entity.SqlServer....
693
votes
23
answers
293k
views
SqlException from Entity Framework - New transaction is not allowed because there are other threads running in the session
I am currently getting this error:
System.Data.SqlClient.SqlException: New transaction is not allowed because there are other threads running in the session.
while running this code:
public class ...
2
votes
2
answers
118
views
How to call var scope = ScopeFactory.CreateScope(); and still have one depency resolved from rootProvider
I have situation like this: I have two Blazor components, both using dbContext and I get popular error
A second operation was started on this context instance before a previous operation completed. ...
611
votes
22
answers
419k
views
Unable to update the EntitySet - because it has a DefiningQuery and no <UpdateFunction> element exist
I am using Entity Framework 1 with .net 3.5.
I am doing something simple like this:
var roomDetails = context.Rooms.ToList();
foreach (var room in roomDetails)
{
room.LastUpdated = ...
0
votes
1
answer
91
views
How to resolve EF Core continuous migration error with npgsql HiLo?
I'm using Hilo with a custom sequence name. When creating migrations, EF Core always creates a migration to drop the sequence with the normal name. Since EF Core 9.0, this produces a runtime exception ...
469
votes
28
answers
521k
views
Conversion of a datetime2 data type to a datetime data type results out-of-range value
I've got a datatable with 5 columns, where a row is being filled with data then saved to the database via a transaction.
While saving, an error is returned:
The conversion of a datetime2 data type ...
0
votes
0
answers
44
views
I can't create my custom filter in HotChocolate 13.5.0, where can I view detailed documentation or code examples?
I'm trying to create my own filter for a specific type of data in hotchocolate.
I created a class from FilterInputType<MyType> and specified an additional field for filtering in it. For this ...
1
vote
0
answers
148
views
Orphaned pg_temp_# and pg_toast_temp_# schemas in postgresql 17.5 slow down ORM model update
I am running PG 17.5 Windows using the EDB community distribution. I am using Entity Framework ORM with Devart's dotConnect for PostgreSQL. The issue I am about to describe did not occur under PG 13....
270
votes
30
answers
289k
views
No connection string named 'MyEntities' could be found in the application config file
I am using entity framework and ASP.NET MVC 4 to build an application
My solution is split into two projects;
A class library that includes my data model (.edmx) file and a few custom interfaces
The '...
868
votes
17
answers
295k
views
Entity Framework vs LINQ to SQL [closed]
Now that .NET v3.5 SP1 has been released (along with VS2008 SP1), we now have access to the .NET entity framework.
My question is this. When trying to decide between using the Entity Framework and ...
216
votes
25
answers
380k
views
The instance of entity type cannot be tracked because another instance of this type with the same key is already being tracked
I have a Service Object Update
public bool Update(object original, object modified)
{
var originalClient = (Client)original;
var modifiedClient = (Client)modified;
_context.Clients....
357
votes
45
answers
424k
views
Entity Framework: "Store update, insert, or delete statement affected an unexpected number of rows (0)." [closed]
I am using Entity Framework to populate a grid control. Sometimes when I make updates I get the following error:
Store update, insert, or delete statement affected an unexpected number of rows (0). ...
384
votes
18
answers
330k
views
Reset Entity-Framework Migrations
I've mucked up my migrations, I used IgnoreChanges on the initial migration, but now I want to delete all my migrations and start with an initial migration with all of the logic.
When I delete the ...
69
votes
27
answers
164k
views
An error occurred while accessing the Microsoft.Extensions.Hosting services when do first migrations
I don't understand what wrong.
I tried to make a simple crud in .net core mvc with a very simple model which has few fields.
These are my models:
public class Employee
{
[Key] public ...
0
votes
1
answer
103
views
Why can't Entity Framework soft-delete via SaveChanges? (and an alternative solution)
I want to implement "soft delete" in my application, meaning that instead of physically removing records from the database, I set an IsDeleted flag to true. My expectation is to intercept ...