Questions tagged [ef-database-first]

The Database First Approach of Entity Framework provides an alternative to the Code First and Model First approaches to the Entity Data Model and it creates model codes (classes, properties, DbContext etc.) from an existing database.

The Database First Approach of Entity Framework provides an alternative to the Code First and Model First approaches to the Entity Data Model and it creates model codes (classes, properties, DbContext etc.) from an existing database.

731 questions
7
votes
2 answers

"the entity type is not part of the model for the current context" error is thrown when project contains more than one EDMX file

I'm using database first and I have a switch statement that looks something like this: switch (site) { case Site.One: using (OneContext one = new OneContext()) return one.OrganizationObjects.SingleOrDefault(x => x.u_Name ==…
ernest
  • 1,633
  • 2
  • 30
  • 48
7
votes
1 answer

Inheritance and navigation properties to child entities

I have a problem with Navigation Properties while I'm using Inheritance (TPH - the only available at the moment in EF Core). My hierarchy models: public class Proposal { [Key] public int ProposalId { get; set; } [Required,…
Kuba
  • 1,415
  • 1
  • 18
  • 29
7
votes
2 answers

T4 code generator for Entity Framework - Failed to resolve include text for EF.Utility.CS.ttinclude

I'm trying to automate build process for CI server of Silverlight 5 application using OpenRIA Services. I've got database-first Entity Framework .edmx generated file from which DomainModel is generated, and as part of build I want to generate…
7
votes
2 answers

Add new table to an existing database using database first approach EF

Now I'm using EF 6 database first in my solution , I have entities that pre-defined in the database. I now need to update the database and add tables ! I can't find the true way to follow
Med MANS
  • 199
  • 1
  • 2
  • 13
7
votes
2 answers

EF DB First refresh is not detecting FKs to a particular table

Not sure what's happened to my setup, but of late, when I update my database with new fields or new tables that have a foreign key to a particular table (Person), my database refresh picks up the new fields, but does not recognize the FK…
Shaul Behr
  • 36,951
  • 69
  • 249
  • 387
7
votes
1 answer

How to use Repository pattern using Database first approach in entity framework

How to use Repository pattern using Database first approach in entity framework.I got some idea while going through resources available on internet but for real time applications I am not sure how to implement repository pattern on the auto…
Rakesh das
  • 73
  • 1
  • 1
  • 4
7
votes
0 answers

Automatically set Store Generated Pattern to Computed when generating from database

Is there anyway to have a properties StoreGeneratedPattern automatically set to Computed in ADO.net when generated from a database where the fields default value or binding is set? Is this also possible with fields that have triggers?
GJKH
  • 1,715
  • 13
  • 30
7
votes
1 answer

Switch from Entity Framework Database First to Code First

Our Solution is currently based on Entity Framework Database First. We have a T4 Template that generates repository classes from the EDMX. We are reviewing our planned approach for releasing changes, especially Database changes. If we continue…
Chris
  • 1,449
  • 1
  • 18
  • 39
7
votes
2 answers

empty .Designer.cs file after generating .edmx using EF 4.x on ASP.Net MVC4 application

I have started a very simple ASP.Net MVC4 applictaion with a Database first approach (with existing DB). I have generated .edmx using ADO.Net Entity Data Model template. The process has created a xxxxxxx.Designer.cs file under xxxxxxx.edmx option.…
PineCone
  • 2,193
  • 12
  • 37
  • 78
7
votes
4 answers

How To Change Navigation Property Names Into Meaningful Names

I'm using Database First with Entity Framework 5. We have two tables (massively simplified): Addresses Street Town (etc.) Customers Name BillingAddress DeliveryAddress AltDeliveryAddress When we use Visual Studio to import the database into EF…
7
votes
2 answers

Best practice for editing MVC3 auto generated code?

Im sorry if this is in the wrong place, however I think it is. So I when creating an MVC3 internet application I used a database first method and my classes were generated for me. I am new to MVC3 and fairly new to c# and visual studio although I do…
Bohdi
  • 1,295
  • 4
  • 28
  • 62
6
votes
2 answers

Add relationships to the ApplicationUser class in ASP.NET Identity (Database First)

I'm using ASP.NET Identity (Database First) in my ASP.NET MVC application. I followed the instructions here, to set up the ASP.NET Identity with database first approach. My AspNetUsers table has a relationship with the Employee table (The Employee…
ataravati
  • 8,891
  • 9
  • 57
  • 89
6
votes
1 answer

Scaffold EF Core from Database Project

How can I scaffold EF Core directly from a Visual Studio SQL Server Database Project? Solutions such as the following are preferred: scaffold-dbcontext -connection "provider=ssdtproject, name=myprojectname.sqlproj" scaffold-dbcontext -ddl…
6
votes
1 answer

Pre-generating Entity Framework Views

I'm working on an MVC 5 application that uses Entity Framework 6.1.3. I'm trying to optimize the first call, which usually takes 1-4 seconds, by pre-generating the views. I understand why this is happening, but I feel like I'm missing an important…
Matthew Meppiel
  • 966
  • 3
  • 14
  • 29
6
votes
2 answers

Use SQL Server database instead of local database asp.net mvc 5 database-first asp.net Identity tables

I have created an MVC Web App using Database First. The default db for the ASP.Net Identity data is a local database. I need to change this to my sql server db which already exists. I have looked everywhere. The only articles about this seem to deal…
EB.
  • 2,627
  • 8
  • 35
  • 55