So I’m currently trying to create a code first migration with Entity Framework Core for a table that displays which lectures the application user has completed. My model looks like this: public class …
Tag: entity-framework
Bulk insert using EntityFramework Extended
According to this, bulk insert in Entity can be made using the following code: I used SQL Profiler to verify how many insert queries were executed and I saw there was an insert for each element of the list. Why? Answer AddRange Add range doesn’t perform a BulkInsert, it simply DetectChanges once after all entities are added to the set.
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 and here ok. Then, I’d like to make a query on MyTable, like The code above will query on my MyTable in the db. Is there a way to query also on the just added value,
Can’t delete a row using entity framework
The problem that I’m having is that I can’t delete a row when using entity. I’m able to find the row, but the error I get the next error: Additional information: Store update, insert, or delete statement affected an unexpected number of rows (0). Entities may have been modified or deleted since entities were loaded. See http://go.microsoft.com/fwlink/?LinkId=472540 for information on
Retrieving SQL Generated by Entity Framework Core
I’m trying to retrieve the raw SQL generated by Entity Framework for the following LINQ query: pagedItemResults = from firstItem in dbData.Accession join secondItem in …
EF – AND NOT EXISTS (SELECT 1 …) with Entity Framework
I am trying to run this query using Entity Framework in my ASP.NET MVC project but I am not succeeding. Could anyone help me do this using LINQ? TABLES: Answer The direct equivalent LINQ construct of SQL NOT EXISTS (…) is !Any(…). So translates to
Using SqlQuery<Dictionary> in Entity Framework 6
I’m trying to execute a SQL query in EF 6. The select query returns two string columns, e.g. select ‘a’, ‘b’, and can have any number of rows. I’d like to map the result to a dictionary, but I can’t …
Anonymous type result from sql query execution entity framework
I am using entity framework 5.0 with .net framework 4.0 code first approach. Now i know that i can run raw sql in entity framework by following It’s working perfectly but what I want is return anonymous results. For example I want only specific columns from student table like following It is not working. it gives exception The data reader
linq to entities query which has multiple where clause and one where clause with where in condition
I’m trying to build a linq to entities query. This is what I have so far: from x in db.BusSchedule join y in db.BusSchedule on x.ID equals y.ID – 1 where Convert….
How do you write a parameterized where-in raw sql query in Entity Framework
How do you write a parameterized where-in raw sql query in Entity Framework? I’ve tried the following: But as expected, it throws an error on DateParam because it’s expecting a single value. Answer This isn’t a problem specific to entity-framework, you can solve it by generating your own parameter names dynamically. The resulting query sent to SQL-Server will look like