Questions tagged [database-first]

171 questions
1
vote
1 answer

EF update model from SQL Server 2016 database takes too long

The project I work on uses the process of database first, update EF model from db afterwards. I face the following problem: if the database is in "compatibility level SQL Server 2016", my update of the model from database never returns (takes…
user1788742
1
vote
1 answer

Getting "the wait operation timed out" on simple query, other queries work, works on local db

I have a very simple LINQ query where I call a view to get an object, basically it looks like this: context.view.FirstOrDefault(p => p.id == key) Key and id are strings, which is less than ideal I think. However, when I run it against my local…
Chip Potato
  • 155
  • 1
  • 7
1
vote
3 answers

Linq-to-sql many-many in database first

I have a database with 2 table Song vs Artist mapping by Mapping_Artist_Song, then i add existing database to models(database first) in my project and now i dont know how to use linq to select song have same id but difference artist in database :…
Tan Sang
  • 1,897
  • 1
  • 16
  • 28
1
vote
2 answers

EntityFramework v6. Database first. Not Decorating property with Key even though table has Primary Key

I choose Database First: Here is an example table that is experiencing this issue. As you can see the EntityId column is the Primary Key: The imported table in the model browser shows that it has the Primary Key: But the code for the generated…
party_Rob
  • 77
  • 7
1
vote
2 answers

MVC ModelState error "The ID field is required" although the database generates an ID

I created the MVC application database-first with the ID field being generated by the database. Since the ID is generated by the database, in the Model I set the 'StoreGeneratedPattern' property to 'Identity'. However, I am still getting the…
abiNerd
  • 1,976
  • 1
  • 18
  • 22
1
vote
1 answer

ASP.Net Identity Connect to Existing Non Identity Tables

I'm working on a project in asp.net mvc. I want to authenticate users using Asp.Net Identity and Owin. I'm aware that Identity has its own tables which are created using code first approach. However, I want Identity to connect to our existing…
1
vote
1 answer

web api http get gives "Create Database permission denied in database master"

I have a database called XyzDB. Everything is done and I am happy with it. I have a WebAPI project which used Entity Framework (I generated my entity models from my database, so not code first). When I use fiddler to query a table with a simple Get…
1
vote
1 answer

Generate Enum from Lookup Tables - EF 6

This might sound repeated but I have gone through all the available posts but could not figure out the best method in EF 6 version. I have two tables PersonPhone (PersonID, PhoneTypeID) PhoneType(PhoneTypeID, Description) PhoneTypes as just look…
1
vote
0 answers

EF - could not find a model

I have 2 similar DBs. So, both DBs have tables AllowedDates and AllowedTimes (with the same structore). I try to connect to these 2 DBs in my project. I created first model (DB.edmx) for first DB and second model (TEX.edmx) for second DB. Also, I…
Oleg Sh
  • 8,496
  • 17
  • 89
  • 159
1
vote
1 answer

Manage EF6 database first many to many relationship

I have an EF6, MVC4 database first web application. The database model has some many to many relationships defined, and the .edmx model is showing them the right way. The trouble is when I try to make an insert to my database, I have no option to…
1
vote
1 answer

Is it possible to alter database using EntityFramework- Database First workflow

is it possible to change database tables (e.g adding a field in a particular table) in an application using Entity framework.?? My application used an existing database to generate a model nd entity classes out of that database, if now I want to…
1
vote
5 answers

Entity framework not creating .cs file for new table

I'm using Entity framework 5 with a database first approach. I created a new database table and updated my .edmx. The .cs file was not created for my Model.tt, as explained here this is a bug in VS 2012. I followed the work arounds as explained in…
Andre Lombaard
  • 6,985
  • 13
  • 55
  • 96
1
vote
0 answers

Use complex type in stored procedure when inserting data to the database, using entity framework

I am using database first in an MVC application, and in certain situations I need to use stored procedures to map data from the database to complex types (and vise versa). It was easy to setup the mapping to complex types, when reading data from…
1
vote
2 answers

Entity Framework Database-First Collections

Ok, so I have myself a generated class called Vault.CS which was generated from my database table "Kingdoms". "Kingdoms" is seperated into 3 conceptual models called "Kingdom", "Army, "Vault". Vault is a conceptual model that refers to the…
1
vote
1 answer

Pulling related data in MVC 3 from separate database

Being new to MVC and the Entity Framework I've had quite a few problems performing complex data queries. I'm using a Database First approach I need to understand the best way to pull related data from a separate database. I have connected to the…