Questions tagged [code-first]

Code-first is a software implementation approach that favors programming against an API over other approaches that may rely more heavily on visual tools or require the presence of some external source that is inspected to generate program behavior, structure, or data.

Filter by
Sorted by
Tagged with
0 votes
0 answers
19 views

How can I configure DbSet with an ICollection<T> in DbSet<Element<T>>

I have a Domain as described below; Can I configure EntityFramework to have a single table for Elements and a single table for both ItemA and ItemB??? public class Element<T> where T : ItemBase {...
ScottBarnesBass's user avatar
0 votes
1 answer
38 views

Entity Framework Core code-first approach: database not being created automatically [duplicate]

I'm having an issue with Entity Framework Core while trying to use the code-first approach. I want the database to be automatically created when I run the code, but it's not happening. If I don't ...
Mert Atmaca's user avatar
0 votes
0 answers
39 views

Java Spring for Graphql - Code-first - how to generate schema with dynamic input types

I want to generate GraphQL schema files from Java model, specifically for input operator filters for each field similar to https://www.mongodb.com/docs/atlas/app-services/graphql/types-and-resolvers/#...
Stupify's user avatar
0 votes
0 answers
109 views

Swagger with abstract Class hierarchy, should work

Ok, lets step in of what we have and the issues we are currently facing.... We have a data model, pretty close to that what is available in other examples. (all code here in github: https://github.com/...
beagle's user avatar
  • 137
1 vote
0 answers
21 views

Givinig range in relationship for entity model in .NET Core

I have two models with the relationship as below (i.e 1 to 1-3). i.e model class A has at least one but not more than 3 instance/record of class B. How will I specify this relationship? public class ...
Rashedul.Rubel's user avatar
0 votes
1 answer
53 views

How can I use GRPC versioning in a code-first approach?

As you can see in Versioning gRPC services, in GRPC we can use versioning by defining package in a proto file. How can I achieve the same functionality in a code-first approach?
sorosh_sabz's user avatar
  • 2,366
0 votes
0 answers
49 views

How to choose GUID as the primary key in SQL compact?

Hi I create C# windows form project and use "Microsoft® SQL Server® Compact 4.0 SP1" as database. I create my project with entity framework and code first approach. but I get some error. I ...
sadegh's user avatar
  • 105
0 votes
3 answers
57 views

How to create relation between one entity and others entities types using child id and child type in C# .net core EF?

I want to create a direct relation between the Task entity and the child entities, to get with the task the corresponding child and when I get the child to get the corresponding task. I have an entity ...
Florin's user avatar
  • 41
1 vote
1 answer
107 views

How To Generate View Models From Code-First Entity Classes Using CodegenCS?

I have a set of entity classes for a Code-First approach. Is it possible to use CodegenCS to generate View Models from these class definitions? I am finding it difficult to figure out a way, let alone ...
Aaron's user avatar
  • 111
0 votes
0 answers
62 views

Which approach to choose in API management: "Code first" vs "Spec first"?

I need to decide, which approach to use in our project. I personally stick to the "Spec first" approach (or "Design first" approach). It means, that we first design an API ...
Constantine Malyshev's user avatar
0 votes
1 answer
14 views

telerik sheduleview wpf code first with entity framework core

I am new to .net core, here is the official repository from telerik for code first approach on schedule view : https://github.com/telerik/xaml-sdk/tree/master/ScheduleView/DatabaseEntityFramework if ...
traderset's user avatar
0 votes
1 answer
191 views

Remap foreign key constraint after table rename with EF Core code first migration

I have to rename a table A that is targetted by a foreign key constraint of another table C. I then have to add a new table B and remap the old foreign key constraint link "A <-> B" to ...
Razzupaltuff's user avatar
  • 2,250
0 votes
0 answers
17 views

Get Connection String Out of Publish settings and URL

I have a publish settings file to deploy my asp core 5 code first application. I am stuck at part how to publish my database. i have publish url but i can't get connection string to be valid let's say ...
manora's user avatar
  • 23
0 votes
0 answers
40 views

EF Core and ALTER TABLE statement conflicted with the FOREIGN KEY CONSTRAINT

I have the following Dtos public class OrganizationDto { public OrganizationDto() { } public OrganizationDto(string name, string subscriptionPlan) { Name = name; ...
mrhusky's user avatar
  • 31
0 votes
1 answer
179 views

EF Core enum collection property comparing

I'm using code first with Entity Framework Core for handling som addresses in an application. These addresses all have a HousingTypes property which is a collection of enums that can by any of the ...
einord's user avatar
  • 2,278
0 votes
0 answers
486 views

Entity Framework Core 7 Does not allow nullable foreign Key

The thing that i want to achieve is when a category deleted related column in the book, that categoryId must change as null, i write a delete behaviour method with set null. However, a nullable ...
Canberk's user avatar
0 votes
0 answers
95 views

How to fix "Non-exhaustive switch expression failed to match its input. Unmatched value was Unchanged."

A user can add an event they want to their favorites. Below are the entities I have opened for this and the links between them. Event: public class Event : EntitySoftDeletableIntKey { public ...
dogac's user avatar
  • 47
0 votes
0 answers
43 views

"Define the key for this EntityType." I get that error. But I already defined the key -- Entity Framework code-first

System.Data.Entity.ModelConfiguration.ModelValidationException: 'One or more validation errors were detected during model generation: // i get that error. I already defined the key but it is not ...
overload's user avatar
0 votes
0 answers
108 views

How to get string[] array from database with EF core [duplicate]

I got one big question. Below is the code I used to store string[] arrays in database, but I cannot Get them from database. my Model: public class TokenTransaction { [Key] public int Id { get; ...
azita's user avatar
  • 11
0 votes
1 answer
171 views

How to Stop the Entity Framework Code First from running “CREATE SCHEMA IF NOT EXISTS”

Here is info about our technical development environment : .NET Core 3.1 PostgreSQL 14.2, compiled by Visual C++ build 1914, 64-bit EntityFramework.Functions Version=1.5.0 Microsoft....
crazyTech's user avatar
  • 1,381
0 votes
1 answer
87 views

How to use GroupBy() and Min() with Entity Framework Core ASP .NET

Let's say my database table Agents is the following, +------------+----------------------+--------------------+------------+-----------------+---------+ | AgentCode | AgentName | ...
Lakshitha Kanchana's user avatar
0 votes
0 answers
92 views

A network-related or instance-specific error occurred while establishing a connection to SQL Server. Code-first ef core 6

I am building my first application using .Net 6 EF Core. I want to use the code-first method. When I try to migrate using Update-Database (after I get this error: A network-related or instance-...
calket's user avatar
  • 11
0 votes
2 answers
379 views

How to change foreign key suffix in Entity Framework Core?

In EF Core with a code-first approach, by default column referencing another entity has an Id suffix - for example PersonId. Is it possible - and if so, how? - to change it to _id, so to person_id?
Rico's user avatar
  • 164
0 votes
2 answers
206 views

Why can I not submit a form with a navigation property with Entity Framework?

I am learning C# and I have been running into a lot of issues with my first project around navigation properties. The main hurdle I am having an issue with is a basic four property model (and anything ...
alexander7567's user avatar
2 votes
2 answers
849 views

How to automate DB setup of Entity Framework's Code First in Testcontainers for testing?

In order to setup the Testcontainer's MsSqlTestcontainer for testing, I copied the script emitted by dotnet ef migrations script and planted it in the unit-test's setup (actual code doesn't : void ...
Tar's user avatar
  • 8,559
-1 votes
2 answers
850 views

Error when trying to create a C# EF core migration, System.NullReferenceException: Object reference not set to an instance of an object

I am practicing dependency injection in C# Winforms .Net 6.0. I have separate projects for DAL, BAL, Services, and the WinForms app. At the moment of injecting the dependencies in the Program.cs, ...
MARIO ESTRADA's user avatar
1 vote
1 answer
99 views

Defining entities in nestjs graphql code first approach with custom field results in error

I am using NestJs along with GraphQL with code-first approach as explained in the documentation. It works correctly till the time I have to use a custom field in an entity which is an array of objects....
Neha Alreja's user avatar
2 votes
2 answers
2k views

The foreign key property 'fk1' was created in shadow state because a conflicting property with the simple name 'property'

I'm creating my database using code-first and entity framework core, I have a 1:1 relationship, but in this relationship, I have a navigation property in both entities, this is my first entity: public ...
Andres Guillen Hernandez's user avatar
0 votes
1 answer
88 views

How to create an array in the GraphQL's argumment as GraphQL Code First Approach

In GraphQL Code First Approach I am trying to pass the same argumment for createUser in createManyUser but I want to pass it as an array to create many users at once. I searched a lot but couldn't ...
Maher Aldous's user avatar
0 votes
1 answer
63 views

Entity Framework assign multiple foreign key - code first approach

I don't know how to add two foreign key in the following scenario: I have two tables, one exists in the database yet (table Market), and I have to create a new table (MarketBranch). Table Market: ...
user18363545's user avatar
5 votes
0 answers
787 views

How to set Apollo's cacheControl Directive in Nestjs code-first

I am trying to set a static cacheControl on some fields, as done here From my understanding, I need to use a directive, so I used the following nest documentation to declare directives So, I built a ...
way2mor's user avatar
  • 51
3 votes
1 answer
71 views

New web project design pattern specification

I have a relational database with more than 50 tables. They have more than one type of relationship, one to one, more than one. Will code first or database first be more effective in the new MVC ...
user avatar
0 votes
1 answer
105 views

Code-first Entity Framework : foreign key - invalid object name

I'm having trouble with Entity Framework and the code-first approach. Foreign key will not link properly Here is the error page: (https://prnt.sc/JUWTdRVCEWq7) public class Organisme { public int ...
120 099 101 105 110 103's user avatar
0 votes
1 answer
42 views

How can I add two property in my model in EF code first from one model?

I want to add two properties from the city model: after migration this error shows up: Unable to determine the relationship represented by navigation 'City.Orders' of type 'ICollection'. Either ...
Hamza abu-othman's user avatar
0 votes
1 answer
415 views

how to select first not null field in each group when group by in dot net entity code first

I have a Model with a field type of string. I want to make a query in group by get first item of each group. but with this condition that first item string field is not null i run this query in my ...
mhsankar's user avatar
  • 423
0 votes
1 answer
900 views

Postgres: SequelizeDatabseError: column id does not exist

I am using Postgresql with code-first approach in my Node.JS project. Some of the tables were already there in the inherited code. There is a table called user_games storing the information about ...
Sandeep Parashar's user avatar
0 votes
1 answer
921 views

Npgsql.PostgresException: type "ltree" does not exist

I'm developing a WebAPI with asp.net core [net5.0] DataBase: PostgreSQL Provider: EF Core Approach: Code First In domain objects I've used Ltree for hierarchy. While adding and updating migration, ...
Maruf's user avatar
  • 374
0 votes
1 answer
229 views

UseLazyLoadingProxies codefirst null navigation property only after database creation

Problematic code (Present in Core.run() below) user.UserWordRequests.Add( new UserWordRequest { Date = DateTime.Now, Word = word } ); Decription of problem Database doesn'...
Dani's user avatar
  • 1,825
0 votes
0 answers
60 views

In C# how do I get Conventions from Context object in EF 6?

I would like to get Conventions that were created on OnModelCreating, from my context object. Example: public class MyContext: DbContext { public MyContext(): base(System.Configuration....
Gustavo Rosa Monteiro's user avatar
0 votes
0 answers
25 views

ASP.NET MVC code first, foreign key to Sharepoint table

Maybe someone can help me with my problem: Problem I am working with ASP.NET MVC and have created a simple website with a database behind it. In this database I have different tables, but the ID of ...
jommil's user avatar
  • 21
2 votes
0 answers
233 views

How do you define a GraphQL host type using a code-first field resolver?

I am using NestJS with TypeORM to connect with a MongoDB server running on a docker image. I am getting this error when trying to start the application: type-metadata.storage.js:263 throw ...
Joachim Rives's user avatar
0 votes
0 answers
94 views

How to create data without out of range exception

I tried to create data by using code first to finish my OOP assignment. However, when I created connections among class, I encountered a problem: System.ArgumentOutOfRangeException: 'Index was out of ...
Văn Thuận Nguyễn's user avatar
-2 votes
1 answer
45 views

3 table relationship

I'm trying to estabilish relationship between 3 tables in c# My models are: Guitar: public class Guitar { [Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] [Required] public ...
bence győgyei's user avatar
2 votes
2 answers
1k views

How to store a List of enum using EF 5

I am currently working on a small project with code-first: I have to create a movie database and as usual each movie can have more than one genre (m:n). Since genres are constant, I decided to create ...
user avatar
0 votes
1 answer
2k views

Nestjs define GraphQL Object type got this error: Schema must contain uniquely named types but contains multiple types named "Address"

I use Nestjs & GraphQL for backend development, when I define model class (code first), I got following error: Schema must contain uniquely named types but contains multiple types named "...
Michael's user avatar
  • 27
0 votes
0 answers
46 views

EF Code-First Data Type Conflict between MySQL and Oracle

I using EF code-first approach for tow databases engine (Oracle and MySQL). but I have problem when declare property with decimal type then I cant apply database migration in oracle database because ...
Raed Alsaleh's user avatar
  • 1,581
25 votes
2 answers
10k views

EF Update-Database Error: Value cannot be null Parameter name: type

I try to execute command update-database in PMC and always get this error msg. I know theres another article basically has the same error but i tried every answer and nothing works. System....
somniloquist_'s user avatar
1 vote
1 answer
477 views

Create a Table in different File-group with EF core code-first

I want to create a table in the "Secondary" file group which has been created previously in the SQL Server 2016. I want to create this table with EF core code-first.
Mahdi Abyaznezhad's user avatar
3 votes
3 answers
1k views

How to create a category table that has SubCategories using EF Core Code-First? [duplicate]

I have created a simple table named "Category". Each category could have one or more subcategories or they could have no category. I can't do it using EF core Code-First in ASP.NET 5. Would ...
Pouria sh's user avatar
0 votes
1 answer
477 views

How to save array of int type in database using ajax call in .net mvc?

I need to save my tags in the database using their ids. I will get the tags id in arrays using ajax but don't know how to code the controller so my tags are saved in the table. I would need to know ...
Malik Khabab's user avatar

1
2 3 4 5
48