zzz projects Entity Framework Core EF Core
Home Articles Knowledge Base Online Examples
  • Home
  • Articles
  • Knowledge Base
  • Online Examples

Entity Framework Core - Knowledge Base (KB)

39 results in tag: entity-framework-core-2.1

How to UPDATE modified and deleted entities on SaveContext?

Goal is to track who had changed and deleted an entity....So I have an entity that implements an interface:...interface IAuditable { string ModifiedBy {get;set;} } class User: IAuditable { public int UserId {get;set;} public string UserName {get...
c# entity-framework-core entity-framework-core-2.1
asked by Roman Pokrovskij

The seed entity for entity type 'X' cannot be added because the was no value provided for the required property "..ID"

I'm playing wit ...EF Core 2.1 Preview 2.... I have troubles with HasData (Seed) method in ...OnModelCreating(ModelBuilder modelBuilder)...My model is simple POCO class that has no annotation....public class Tenant { public int TenantID {get; set;} ...
c# entity-framework-core entity-framework-core-2.1
asked by Tomino

EF Core Group By translation support on conditional sum

I was really excited to hear that EF Core 2.1 will be supporting group by translations. I downloaded the preview and started testing it out but found that I am still not getting group by translations in a number of places....In the code snippet below, the...
c# entity-framework-core entity-framework-core-2.1
asked by jaromey

Entity Framework Core: Fail to update Entity with nested value objects

I have an entity that has a value object and this value object has another value object. My issue is that when updating the entity along with the value objects, the entity with the parent value object get updated but the child value object didn't. note, i...
c# entity-framework-core entity-framework-core-2.1 value-objects
asked by yo2011

How to create relationships between entities with existing database that does not contain foreign keys

Using Entity Framework Core 2.0...Stuck with company's production database which has primary keys defined for each table but no foreign keys defined for any relationships....Dependent records in the database have id fields which are intended to relate to ...
entity-framework-core entity-framework-core-2.1
asked by JakRuzL

'No database provider has been configured for this DbContext' using SQLite

I'm just experimenting with EF Core and SQLite and have been slightly stumped by the issue....If I attempt to configure the database like this:...services.AddDbContext<MyDbContext>(options => options.UseSqlite("Filename=./App_Data/dashboard.db") ); ...And...
asp.net-core c# entity-framework-core entity-framework-core-2.1 sqlite
asked by Jammer

How to get all saved Entity values in DbContext either via Events or override SaveChangesAsync()

Need a centralized solution to get the resulting ...Entity... as persisted to the Db, potentially inside the ...SaveChangesAsync()... and ...SaveChanges()... methods of my ...DbContext... or via an event listener....Need resulting entity value to contain ...
c# entity-framework-core entity-framework-core-2.1
asked by ttugates

Scaffolding Keyless Models on entity framework core 2.1

I have a simple console app and i am trying to scaffold all my models but i have some of them that does not have defined a primary key, Entity framework 2.1 give support to that kind of tables but still get this warning ...Unable to identify the primary k...
entity-framework-core entity-framework-core-2.1
asked by Dennis Gonzalez

EF Core 2.1 project Add-Migration NullReferenceException

I am getting a ...NullReferenceException... on a project recently converted to dotnet core 2.1....My EF library project is dotnet core 2.1. Code first migrations....CsvHelper 6.0.2 Microsoft.EntityFrameworkCore 2.1.0 Microsoft.EntityFrameworkCore.Design 2...
asp.net entity-framework-core entity-framework-core-2.1
asked by Padhraic

EF Core Migration error: Database 'MyDatabaseName' already exists. Choose a different database name

I am running ASP.NET Core 2.1 with EF Core 2.1 application on Windows Server 2016 with SQL Server 2017 Web edition....At the end of ...public void Configure(IApplicationBuilder app, ...... method in ...Startup.cs... I call ...context.Database.Migrate();..
entity-framework-core entity-framework-core-2.1 entity-framework-core-migrations
asked by Makla

EF CORE: is it possible to support two models in one database?

Is it possible to support two different EF Core models with all "migrations functionality" in one database? ...I guess I should somehow separate ...dbo......._EFMigrationsHistory... ? Can't find such option in documentation.
ef-migrations entity-framework entity-framework-core entity-framework-core-2.1
asked by Roman Pokrovskij

Get related data without relationship between tables

When I have two models with one to many relationship, they look like the models below:...public class Student { [Key] [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)] public int StudentID { get; set; } public string Name { g...
entity-framework-core entity-framework-core-2.1
asked by pitaridis

Entity Framework Core - More than one Discriminator for derived classes

I have a model that is structurd as follows (fields ommited for brevity):...public enum ActivityType { Production, Downtime } public enum ActivityStatus { Planned Actual } public abstract class Activity { public virtual ActivityType ActivityType {ge...
c# entity-framework-core entity-framework-core-2.1
asked by Chris

Combine BinaryExpression and Expression<Func<dynamic, bool>> in C#

How can I combine ...BinaryExpression... and ...Expression<Func<dynamic / T, bool>>...?...For example:...void AddGlobalFilter<T>(Expression<Func<T, bool>> expr) { var parameter = Expression.Parameter(type, "t"); var member = Expression.Property(fi...
c# entity-framework-core entity-framework-core-2.1 expression-trees lambda
asked by Makla

What could cause `UserManager` to return the wrong user?

Something rather scary is happening on my ASP.NET Core 2.1.0 MVC site. While I was browsing, all of a sudden it shows I am logged in as a different user (who also happens to be browsing the site at that time)....I can't pinpoint whether there is a specifi...
asp.net-core asp.net-core-2.0 asp.net-core-mvc entity-framework-core entity-framework-core-2.1
asked by Steven Jeuris

Execute async non selectable stored procedure in EF Core 2.1

I'm trying to execute async non selectable stored procedure in EF Core 2.1.... return Ok( await db.Set() .FromSql($"EXECUTE PROCEDURE MY_PROC({id})") .ToListAsync()); ...Error...:...The type arguments for method ...
asp.net-core asp.net-core-2.0 asp.net-core-webapi entity-framework-core entity-framework-core-2.1
asked by mrapi

Entity Framework Core 2.1 - Generic Model in FromSql method

I have been using the below approach to call stored procedure in EF core 2.1...In DBContext...public DbQuery<SomeModel> SomeModels { get; set; } ...Class...var result = context.SomeModels.FromSql("SQL_SCRIPT").ToList(); ...I'm trying to create a generic m...
entity-framework-core entity-framework-core-2.1
asked by VPP

EF Core tracking entities with same id multiple times

I simply want to update an industry property of a client object. To do so, I retrieve the client from the DB using a repository. This would result in my industry (example id:149) being tracked. ... var client = await _clientRepository.GetAsync(...
change-tracking entity-framework entity-framework-core entity-framework-core-2.1
asked by Seb

Many to many self reference table - guid Id changes itself

I have a many to many table that references. Itself it sounds crazy so here's an image for a better view of the problem ...https://i.stack.imgur.com/lj2zZ.png...I use guids as primary and foreign keys. When I try to add a new instance of ...Foo... to the...
.net asp.net-core asp.net-core-2.1 entity-framework-core entity-framework-core-2.1
asked by john

How to do aggregate functions such as count in Entity Framework Core

I have this SQL that I would like to execute in Entity Framework Core 2.1:...Select ItemTypeId, Count(ItemTypeId) as Count from Items i where i.ParentId = 2 group by ItemTypeId ...How do I do that?...This is what I came up with, but it returns zero:...v...
entity-framework-core entity-framework-core-2.1
asked by Greg Gum

Page 1 of 2
  • 1
  • 2
  • ยป

Prime Library

Performance

  • Entity Framework Extensions
  • Entity Framework Classic
  • Bulk Operations
  • Dapper Plus

Expression Evaluator

  • C# Eval Expression
  • SQL Eval Function
More Projects...

Related

  • EF Extensions Online Benchmark
  • WIN an EF Extensions license
  • EF6 BatchSaveChanges for only $79
Get monthly updates by subscribing to our newsletter!
SUBSCRIBE!