Questions tagged [database-first]

171 questions
0
votes
2 answers

Many To Many Relationship / Entitiy Framework Database First with MVC 4 Internet Application

I use MVC 4 Internet Application with VS 2012 and Entity (5.0) Framework Database First.. I created my database with relationships.. I create ADO.NET Entity Data Model.. And I can see all relationships (one-to-one, one-to-many, many-to-many).. I…
yusuf
  • 1,233
  • 1
  • 15
  • 29
0
votes
2 answers

Entity Framework database-first doesn't create the correct model

I'm trying to use the database-first approach with the EF 5.0 and it doesn't create the correct model for me. Here is my data structure: Forums Users Posts Relationships The problem The main problem is with the one-to-one relationships in the…
Imri Barr
  • 1,035
  • 3
  • 12
  • 20
0
votes
1 answer

Entity Framework Database First - Relationships

I think I have CodeFirst understood. Now I know database first EF design is targeted for existing databases, but if I were to quickly go in and create a new database in management studio and create some tables, is it normal that you would create…
TMan
  • 4,044
  • 18
  • 63
  • 117
0
votes
1 answer

Using MVC4 Database-first, how to annotate models with a composite primary key?

I am new to MS's MVC4, and I have been given a database for which I must build a CRUD front-end. The tables all have composite primary keys of the form [TableID, TableName, EffectiveDate]. I cannot alter the database design. I used the…
JohnG
  • 429
  • 1
  • 4
  • 14
0
votes
1 answer

Updating Related Data in an ASP.NET MVC 4

I have 3 tables related with foreign keys Student, Loan and Book, when I create a new student I can relate it with book form table Book and save it also in table Loan, but if I edit in existing student changes are not saved in Student table. …
ilirvg
  • 193
  • 1
  • 2
  • 8
0
votes
1 answer

Get EF 4 database first object property annotation

We are using EF4 database first approach to create all the entities as found in the context class. I'm now trying to add a display name attribute to one of the objects' properties as follows: [MetadataType(typeof(OpportunityMetaData))] public…
James
  • 15
  • 6
0
votes
1 answer

How to convert repository made for Code First to Database First in MVC 3 Application

I'm very new to MVC 3 but not to software so when I decided to start an application in MVC 3, I wanted to make it testable. So I found this great article on how to implement the repository pattern. In this article, at the end, they propose a very…
Jean-François Côté
  • 4,200
  • 11
  • 52
  • 88
0
votes
1 answer

Getting stackoverflow in entity framework with custom get

I'm trying to add business logic to my database first entity framework appplication. I want to limit the length of address1 to 35 and move the rest to address to. In the database the fields are Address1 and Address2, on my edmx it is address1 and…
Antarr Byrd
  • 24,863
  • 33
  • 100
  • 188
0
votes
1 answer

Adding to EntitySet not working

I'm trying to add an object to a database-first ORM EntitySet in an MVC project. I use a piece of code something like this: public static Boolean CreateListing(string title, string description) { ListingEntities ce = new ListingEntities(); …
Bondolin
  • 2,793
  • 7
  • 34
  • 62
0
votes
1 answer

Defining generic repository for entities in EF DatabaseFirst

I am moving from CodeFirst to DatabaseFirst to map my views. In my CodeFirst approach I had a base entity like this: public abstract class BaseEntity { /// /// Gets or sets the entity identifier /// public…
Mert Akcakaya
  • 3,109
  • 2
  • 31
  • 42
0
votes
2 answers

Represent View Without Key in Entity Framework

I'm using a model produced with Devart Entity Developer (.edml file, which I understand is mostly similar to .edmx) to generate Entity classes whose relations are initialized in a DbContext class. The database schema specifies no PK for View1, and…
ossek
  • 1,648
  • 17
  • 25
0
votes
1 answer

Updating a method in Entity Framework

I'm new to Entity Framework and am using Database First. I have inherited a project where I am making changes. I have a table called Bid to which I've added column Auciton_Status_Id. I then updated the .edmx file (whatever that is for) by opening…
Sachin Kainth
  • 45,256
  • 81
  • 201
  • 304
0
votes
1 answer

Code First model and deployment of new versions of the software

I'm looking on Entity Framework at the moment and working with Code First example. So far I can see that the framework does not handle model changes easily: whenever I want to add another field to a class/table, framework drops the entire database…
trailmax
  • 34,305
  • 22
  • 140
  • 234
0
votes
1 answer

How to solve field wrapping in Entity Framework database-first

When I use database first, after creating the edmx file, all the conceptual models have already been generated. But I want to do some special operations on certain fields. For example, there's a field named 'price'; I want the matching property…
James
  • 2,570
  • 7
  • 34
  • 57
0
votes
2 answers

EF 4.1, database first and Many-to-Many relationships - How to get all sub-objects?

Let's say I have the following tables in a database forming a Many-to-Many Relationship. And in an ASP.Net MVC project using EF 4.1, I have corresponding POCO entities and a Repository layer to access the database. People: PersonId PK, Firsname,…
1 2 3
11
12