Category "entity-framework"

EF Core: Map Many to Many relationship without navigation property

I'm trying to create a many to many relationship in entity Framework Core using Fluent API Here is my first model: MyCalculationSelector.cs public int Sort

Read information of ID causing error from Exception

In C# My Sql Entity Framework 6 Insert is return exception Cannot add or update a child row: a foreign key constraint fails (portaldb.masterselectionhistory, C

Entity Framework. How to map class with nested Enumeration class

I am using an Enumeration class like this public class SizeUnit : Enumeration { public static SizeUnit Inch = new SizeUnit(1, nameof(Inch)); public static

How skip some migrations in ef core?

I had some changes in my ef context and I added new Migraions dotnet ef migrations add changed98112601 then I run the below command dotnet ef database upd

Entity Framework .Include() with condition not working

SCENARIO If I split the Entity Framework linq query to evaluate an IQueryable first and after try to include some properties, the value of AccessGroupAccessPoin

Passing parameter to DbContext with DI

I want to pass an additional parameter to the DBContext, like this string myParam="xx"; string con="connenctionstring"; services.AddDbContext<IDbContext, DbC

Multiple Objects stored in database ASP.NET Entity Framework

Can I make the below changes to my databse whilst maintaining the one-to-many relationship? Would my Airport class need to change at all? Existing Flight class:

C# LINQ single query to complete an incomplete model

I have a list of incomplete product models. Everyone is missing an owner and a price. Can these deficiencies be filled with a single query to context? Without t

Getting an invalidcastexception when trying to retrieve data

When running the get method to return a view populated with details, I get the exception saying: System.InvalidCastException: 'Unable to cast object of type 'Sy

EF Core 3.1 The property 'Geometry.UserData' could not be mapped

I have a database-first .net core 3.1 web application which connects to SQL Server database table with a geography column. The database scaffolding and applicat

Move Identity Tables To Custom Schema Asp.Net Core

I Try To move all my identity Tables to Schema "User" using the following code in my context. it works fine for all except "AspNetUserClaims", "AspNetRoleClaims

CreateDbCommandDefinition in the custom DbProviderServices not called?

I need to intercept the call to the following method of DbProviderServices: DbCommandDefinition CreateDbCommandDefinition(DbProviderManifest providerManifest, D

How can I create a partitioned table in EF Core?

Let's say I have an object like this: public class ObjectA { public int Id {get;set;} public DateTime CreatedOn {get;set;} ...etc } I want to partitio

EF Core executing previously failed query on SaveChanges

We have a .Net Core 3.1 application which is using EF Core to connect wit the SQL Server database. We are facing one problem, that when an exception occurs in o

EF Core executing previously failed query on SaveChanges

We have a .Net Core 3.1 application which is using EF Core to connect wit the SQL Server database. We are facing one problem, that when an exception occurs in o

How can I use DB first approach in .NET Core 6?

I try to use Entity Framework in a minimal API running in a .NET Core 6 project. As far as I understand I should run dotnet ef dbcontext scaffold xxxx which I d

Can't find single property and navigate related data without IQueryable all properties

I have relational data properties on my objects that I would like to access: public class Person { public ICollection<Address> Addresses { get; private

.NET Core Entity Framework how to map nested class into one sql table

I'm still new to .NET Core. I have this character that I want to store in SQLite using an entity. But by default, Character, CharacterData and CharacterLine are

C# Adding a NOLOCK to a user-defined EF query

I have the following user-defined query: var outerRingEntities = await Databases.OuterRing.Set<TOuterEntity>() .As

The entity type 'Access' requires a primary key to be defined. If you intended to use a keyless entity type call 'HasNoKey()'

i have this ValueObject : public class Access : ValueObject<Access> { public string ControllName { get; set; } public string ActionName { get;