tagged [entity-framework-core]

Difference between "ToListAsync()" and "AsAsyncEnumerable().ToList()"

Difference between "ToListAsync()" and "AsAsyncEnumerable().ToList()" Function need to return `Task>` Following both options are returning `Task>`, which one is more efficient? Is there any standard w...

Dynamically change connection string in Asp.Net Core

Dynamically change connection string in Asp.Net Core I want to change sql connection string in controller, not in ApplicationDbContext. I'm using Asp.Net Core and Entity Framework Core. For example: `...

How to create a password protected database?

How to create a password protected database? I am trying to create a password protected SQLite database to use within a WPF application using Entity Framework Core. I know how to generate DbContext an...

20 Nov at 15:19

EF Core EnableSensitiveDataLogging does not work as expected

EF Core EnableSensitiveDataLogging does not work as expected I am using EF Core 2.1.1 using MySql and I have the following code to enable logging of the ef core translated to SQL Queries I don't see a...

How to create a table corresponding to enum in EF Core Code First?

How to create a table corresponding to enum in EF Core Code First? How would one turn the enums used in an EF Core database context into lookup tables and add the relevant foreign keys? --- - [EF5 Cod...

16 May at 15:59

EF core not creating tables on migrate method

EF core not creating tables on migrate method Hey I just started using EF core and everything works fine. I call the the `context.Database.Migrate()` method and it creates a database. But even though ...

Seed initial data in Entity Framework 7 RC 1 and ASP.NET MVC 6

Seed initial data in Entity Framework 7 RC 1 and ASP.NET MVC 6 It seems that in Entity Framework 7 there is no native support for seed data yet ([https://github.com/aspnet/EntityFramework/issues/629](...

Raw SQL queries and Entity Framework Core

Raw SQL queries and Entity Framework Core I migrate my application to ASP.NET MVC Core and Entity Framework Core and i found problem. I have raw SQL query to entity like this But there is no `SqlQuery...

Entity Framework core - Contains is case sensitive or case insensitive?

Entity Framework core - Contains is case sensitive or case insensitive? "Contains" in Entity Framework core should equivalent to the SQL %like% operator. Therefore "Contains" should be case insensitiv...

Filtering on Include in EF Core

Filtering on Include in EF Core I'm trying to filter on the initial query. I have nested include leafs off a model. I'm trying to filter based on a property on one of the includes. For example: How ca...

16 Nov at 13:38

DbSet doesn't have a Find method in EF7

DbSet doesn't have a Find method in EF7 I am trying to create a generic repository to access my database. In EF6 I was able to do that in order to get a specific entity: DbSet in EF7 is missing a Find...

30 Jan at 12:19

Get SQL code from an Entity Framework Core IQueryable<T>

Get SQL code from an Entity Framework Core IQueryable I am using Entity Framework Core and I need to see which SQL code is being generated. In previous versions of Entity Framework I could use the fol...

3 Feb at 09:16

How to set command timeout in aspnetcore/entityframeworkcore

How to set command timeout in aspnetcore/entityframeworkcore The place where the command timeout is set is no longer the same as earlier versions. However, I cannot find anywhere that says how to chan...

Where are Entity Framework Core conventions?

Where are Entity Framework Core conventions? using EF 6.1+ there were times where we need to add or remove existing conentions. The code looks more or less like: ``` public class MyContext : DbContext...

19 Oct at 19:37

What is the difference between AddRange and AddRangeAsync in EF Core

What is the difference between AddRange and AddRangeAsync in EF Core I am using EF Core to insert entries and I noticed that when I debug this line of code `context.MyEntityDbSet.AddRangeAsync(records...

21 May at 15:10

How to use FreeText in EF core 2.1

How to use FreeText in EF core 2.1 I see that Entity Framework core 2.1 has a new feature to use `FREETEXT`, but I am not sure how to use it as there are no examples that I can find online. [https://g...

Data Encryption in Data Layer with ASP.NET Core Entity Framework

Data Encryption in Data Layer with ASP.NET Core Entity Framework I am currently designing a web application where the data needs to be stored encrypted. Planned technologies used: - - - - - Which woul...

Override EF Core DbContext in ASP.NET Core WebApplicationFactory

Override EF Core DbContext in ASP.NET Core WebApplicationFactory I have a ASP.NET Core 2.2 WebApi project which uses also EF Core 2.2. The project is tested via integration tests with `WebApplicationF...

Entity framework Core Update-database specific migration

Entity framework Core Update-database specific migration I am trying to figure out how to run a specific migration from the package manager in nuget. I have tried to run: But I do get this message: A ...

8 Sep at 12:26

The LINQ expression could not be translated and will be evaluated locally

The LINQ expression could not be translated and will be evaluated locally Im getting this WARNING in EntityFramework Core what is wrong? I already set MSSQL Datebase to Case Sensitive. Latin1_General_...

Drop database if model changes in EF Core without migrations

Drop database if model changes in EF Core without migrations In previous version of entity framework, one could recreate the database if the model changes, using some of the classes DropDatabseIfModel...

How to get scalar value from a SQL statement in a .Net core application?

How to get scalar value from a SQL statement in a .Net core application? The following code in a .Net core console application (EF core 2.0/Sql server). got the following exception? > Cannot create a ...

5 Nov at 23:11

Using Include vs ThenInclude

Using Include vs ThenInclude I have been experimenting a little with Entity Framework, and after facing the error below, I tried using ThenInclude to resolve it. > The expression '[x].ModelA.ModelB' p...

Does EF Core allow a unique column to contain multiple nulls?

Does EF Core allow a unique column to contain multiple nulls? My entity has a property which is allowed to be null. BUT, if it isn't null, then it must be unique. In other words, the column is unique ...

ASP.NET Core DbContext injection

ASP.NET Core DbContext injection I have a `ConfigurationDbContext` that I am trying to use. It has multiple parameters, `DbContextOptions` and `ConfigurationStoreOptions`. How can I add this DbContext...