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
10 answers

Code-first vs Model/Database-first

What are the pros & cons of using Entity Framework 4.1 Code-first over Model/Database-first with EDMX diagram? I'm trying to fully understand all the approaches to building data access layer using EF 4.1. I'm using Repository pattern and IoC. I know…
20 answers

How to update record using Entity Framework 6?

I am trying to update a record using EF6. First finding the record, if it exists, update. Here is my code: var book = new Model.Book { BookNumber = _book.BookNumber, BookName = _book.BookName, BookTitle = _book.BookTitle, }; using (var…
  • 4,187
  • 5
  • 20
  • 30
9 answers

ASP.NET Identity with EF Database First MVC5

Is it possible to use the new Identity with Database First and EDMX? Or only with code first? Here's what I did: 1) I made a new MVC5 Project and had the new Identity create the new User and Roles tables in my database. 2) I then opened my…
4 answers

How to sync model after using Code First from Database using Entity Framework 6.1 and MVC 5?

Assumptions Using EF 6.1, MVC 5, VS 2013, C# I have an existing database model designed in Toad DM for SQL Server and it's very important keep it always updated Steps and Notes Using ADO.NET Entity Data Model I chose Code First from Database (new…
4 answers

Is there an Entity Framework 7 Database-First POCO Generator?

I've been playing around with Entity Framework 7 and ASP.NET 5 for a new project I'm working on, but I've hit a roadblock. The team I'm working on uses a DBA-first approach to development; i.e. the database is designed by DBA's and then the…
3 answers

EF 6 database first: How to update stored procedures?

We are using Entity Framework 6.0.0 and use database first (like this) to generate code from tables and stored procedures. This seems to work great, except that changes in stored procedures are not reflected when updating or refreshing the model. …
4 answers

Upgrade from Entity Framework 5 to 6

After upgrading our project from using Entity Framework 5 to Entity Framework 6 (though NuGets update function) i get the following error on my generated Entities class: Error 1 The type or namespace name 'Objects' does not exist in the…
7 answers

Adding a New Column to an Existing Table in Entity Framework

I have added a new column to a table in my database. The table is already defined in the existing Entity Framework model. I've been through most of the items here on how to do this and it still fails. A little background, this entity model has not…
1 answer

MySQL Entity Framework 6: Database First. How to create classes?

Until now I've been using EF6 with Visual Studio, mostly code first, rarely database first. To import some test data, someone gave me the connection to a database in MySQL. In MySql Workbench I can query data, so the connection works. Now I want to…
Harald Coppoolse
  • 28,834
  • 7
  • 67
  • 116
3 answers

Scaffold-DbContext (EF Core Tools) throws 'Instance failure' exception

Context Currently I am creating an Extract, Transform and Load (ETL) application written in C# with .NET Core. The target of the ETL application is a database that is accessed through Entity Framework Core 2.1.0 and later 2.1.1. A database first…
1 answer

How to use an existing enum with Entity Framework DB First

I am using Entity Framework 5, DB first. I know how to define an enum on my model, and set the type of a field to that enum. Now, I have a requirement to map a field MyField to an enum that is defined externally, i.e. not in the EF model…
Shaul Behr
  • 36,951
  • 69
  • 249
  • 387
9 answers

How to set created date and Modified Date to enitites in DB first approach

In every SQL table in our application we have "CreatedDate" and "ModifiedDate" column. We are using DB first approach. When i save the data, i want these two column automatically populated. One approach is to have Default Value as getdate() on the…
  • 30,567
  • 53
  • 217
  • 400
7 answers

Unable to retrieve project metadata. Ensure it's an MSBuild-based .NET Core project

I've been researching a lot online but did not find a proper solution. I was trying to use Entity Framework Core with MySQL by using database-first scaffold method to mapping table model while always received this error when applied the…
1 answer

Entity Framework DB-First, implement inheritance

I'm trying to implement inheritance using entity framework 6.0 and database first approach. OK, let's say I have a Person and an Organization entity like below: // a simplified version of organization entity public class Organization { public…
  • 3,322
  • 4
  • 36
  • 47
1 answer

Modelling polymorphic associations database-first vs code-first

We have a database in which one table contains records that can be child to several other tables. It has a "soft" foreign key consisting of the owner's Id and a table name. This (anti) pattern is know as "polymorphic associations". We know it's not…
Gert Arnold
  • 105,341
  • 31
  • 202
  • 291
2 3
48 49