Category "entity-framework"

(.Net Core) How to test connection to db at startup?

.Net 6.0, EF, Asp.Net Core I'm trying to interrupt my web server's startup if the connection to the db could not be established. I'm thinking that the natural p

How to install Entity Framework in a .Net Framework v4.6.1 application using Visual Studio 2017

My first steps in C# are horrible. Now I'm trying to install Entity Framework. For doing that, I just go to the NuGet package manager, I type "Entity" and try t

How to implementing Repository patten with entity frame work mvc

i am trying to implement repository pattern in mvc. but I am stuck. I want to return related data. I have two classes , tbl_Account (contains users )and tbl_Cou

Adding additional records to existing relationship not working

I am trying to add a new Template to an existing Client, but when I try to add the Template with an existing ClientID, it instead adds a new Template with a new

The data types nvarchar(max) encrypted with with (encryption_type = 'DETERMINISTIC' xxx) are incompatible in the equal to operator

var countryCode = new SqlParameter("@countryCode", SqlDbType.VarBinary); var byteArray = Encoding.UTF8.GetBytes(dto.Country); countryCode.Value = byteArray; var

How can I view the .edmx diagram on visual studio for Mac?

I want to view the edmx diagram like below an example of how it is viewed on windows visual studio I have tried looking at Microsofts documentations regarding

How can I view the .edmx diagram on visual studio for Mac?

I want to view the edmx diagram like below an example of how it is viewed on windows visual studio I have tried looking at Microsofts documentations regarding

Entity framework core TPH query across different subtype properties

I'm using EF core TPH inheritance to model some data and I'm trying to write a query that will query across different subtypes. My current attempt at writing a

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