Questions tagged [database-first]

171 questions
0
votes
1 answer

Entity framework: Database first/Code first hybrid

I am trying to create a custom Entity Framework (4.2) entity that would be mapped to my database like it would be done in a Code first approach. The issue is that my entity framework data model is using Database first. How can I add my custom entity…
Bertrand Marron
  • 21,501
  • 8
  • 58
  • 94
0
votes
1 answer

What 'possible data inconsistency' is entity framework worried about in a 'foreign key participating in multiple relationships' situation?

Suppose the following database schema: Table A: AId (PK) Table B: BId (PK) Table C: CId (PK) Table AB: AId, BId (composite PK, FKs to A and B), Data Table BC: BId, CId (composite PK, FKs to B and C), Data Table ABC: AId, BId, CId, Data In the…
AakashM
  • 62,551
  • 17
  • 151
  • 186
0
votes
0 answers

Cannot find ado.net entity data model in visual studio 2022

I want to start a new project in ASP.NET core MVC web application. In the past I'm used to starting with the code, I create the code and I create the dbContext and I make the migration of the data Add-Migration and Update_Migration and finally I can…
0
votes
1 answer

C# Code First Vs. SQL Database first when using a business logic layer

I am firmly in the camp of being a database first developer. I believe there are pro's and cons' to each approach. However when creating a code first approach should the newly created classes have default values set? E.g. public DateTime DateCreated…
Zain Nabi
  • 1
  • 1
0
votes
1 answer

How to call the Session inside ajax based on RoleId in Controller?

I need to call a certain webpage based on Id in user.RoleId which is in my controller and in the script page it needs to call that RoleIdusing session. My Controller: if (ModelState.IsValid) { var user =…
shark
  • 27
  • 6
0
votes
0 answers

How to work and add new table to database first model in asp.net core?

I have an existing SQL Server database that populated with data via another app. I want to work with this database in a new project (ASP.NET Core web application). I know I can add this database to my project by database-first way (write a command…
NedaM
  • 87
  • 3
  • 10
0
votes
1 answer

Add SQL function into project with EF6

I want import my function from SQL Server into my ASP.NET MVC project with EF6 database first. My problem is when I update database in .edmx file, based on what I found in the sources, I open Model Browser but in this file I can't use "Add function…
0
votes
0 answers

Violation of PRIMARY KEY constraint 'PK. Cannot insert duplicate key in object 'dbo.Cursuri'. The duplicate key value is (0)

My assignment is to do crud operations using database first on an Windows Form app. Currently my save button (Salveaza) is not working properly ( I get the above error when I debug it) and I don't understand why. namespace Database { …
Dvalin
  • 31
  • 1
  • 7
0
votes
1 answer

Tuple Problem @model Tuple>

I use database first on my project.I wil save to Profile table and fill a dropdown from department table on this page . How do I use both profile.cs and department.cs in a view in Profile.cshtml? It is a Creating page. This is Profile.cs ; public…
0
votes
1 answer

EF 4.1 DbContextGenerator object names - can they be changed?

I am using DB First EF 4.1 and I am adding DbContextGenerator tt template to my model. This is all great, but I end up with classes like this: public partial class t_city { public t_city() { this.t_neighborhood = new…
Greg R
  • 1,670
  • 4
  • 26
  • 46
0
votes
2 answers

Where to put generated EF 4 files?

I have 3 csprojs in my web application: UI.Web Bll.Web DAL.Web UI.Web references Bll.Web and Bll.Web references DAL.Web. DAL.Web is very simple and only contains methods like: GetDataTableFromSP GetScalarFromSP ExecuteScalarFromSP I reverse…
O.O
  • 11,077
  • 18
  • 94
  • 182
0
votes
2 answers

EF 4.1 Fluent API dB first relationship mapping problem

I have the following tables, Product(pro_iIDX[PK], pro_sName) Manufacturer(man_iIDX[PK], man_sName) ProductManufacturer(pma_iIDX[PK], pma_iProductRef[FK], pma_iManufacturerRef[FK], pma_bAvailable) I have the following POCOs, public class…
0
votes
1 answer

having problem with updating model entity framework in database-first approach

I've used entity framework in my projects and i used database-first approach almost in each time that i change the database ( adding/removing a field to existing table or add new table ) after updae the model , it's becaming unvalid and i receive…
0
votes
0 answers

Does enabling the "read committed snapshot" inside SQL Server 2012, require re-mapping our database tables

I am working on an ASP.NET MVC web application, and we already have a SQL Server 2012 database. So I mapped the database tables inside our ASP.NET MVC using ADO.Net Entity Framework version 5.0, and I got an .edmx model file. I then wrote my code…
0
votes
0 answers

EF database-first approach with 2 databases (test db and production db)

I'm developing a web API with existing database and it has 600k+ records on it. I will be using EF with a database-first approach and planning to clone the production db for staging purposes. I'm planning to generate 2 .edmx models (production and…