Questions tagged [database-first]
171 questions
2
votes
1 answer
EF db first and table without key
I am trying to use Entity Framework DB first to do quick prototyping of a reporting website for a huge db. The problem is one of the tables doesn't have a key. I got an 'Error 159: EntityType has no key defined'. If I add a key on the model…

NS.X.
- 2,072
- 5
- 28
- 55
2
votes
2 answers
Stored procedure not appearing in EF code
I'm using EF database first and have added a stored procedure to the database.
When I ran Update model from database on the edmx file it picked up the stored procedure and I selected it as an item I wanted to include.
I have a file named…

Sachin Kainth
- 45,256
- 81
- 201
- 304
2
votes
2 answers
Entity Framework DbContext Connection string in app.config/web.config not being seen
So, I have followed this instruction from ADO.NET team blog to try to make a small test project.
I have double-checked everything. It doesn't seem to work and keeps saying connection string is…

Tom
- 15,781
- 14
- 69
- 111
2
votes
1 answer
EF: select all entities of subclass (inheritance)
I am using the Database first approach and DbContext.
I have several inheritance structures (TPH) in my data model.
But DbContext only creates one DbSet for the base class, and none for the subclasses.
How should I retrieve all Entities of a…

ckonig
- 1,234
- 2
- 17
- 29
1
vote
2 answers
EF database first & WCF: What about DataContracts?
I'm planning on using EF in a WCF Service. The database that will be used already exists.
I was wondering if I need to map the retreived entities to a datacontract, or can I use them directly?
And on a more general base: are there any pitfalls I…

Koen
- 2,501
- 1
- 32
- 43
1
vote
1 answer
Entity Framework : junction tables with own primary keys
Ì am currently working on a ASP NET MVC project. We use Entity Framework and follow the Database First approach. The database already exists.
The database has been created using the convention, that every table has a specified single primary key,…

ckonig
- 1,234
- 2
- 17
- 29
1
vote
1 answer
EF Database First - Mapping-error 3025
New to EF and trying something out with "Database first".
Error 3025: ... :Must specify mapping for all key properties
(PurchaseUsers.PurchaseUsersId) of table PurchaseUsers.
I have in my db 3 tables:
Purchases …

Koen
- 2,501
- 1
- 32
- 43
1
vote
1 answer
DbContext generator and stored procedures
NOTE: I'm using EF 4.2 with Database First Method and DbContext. This is NOT code first.
I'm trying to get the DbContext t4 tempalate to generate Stored Proc methods. There seems to be functionality built-into it to do so (it maps to the base…

Erik Funkenbusch
- 92,674
- 28
- 195
- 291
1
vote
1 answer
How to connect to a SQL database on MacOS with Entity Framework Core and Database First
I have recently changed from Windows to MacOS and I'd like to make a simple project with ASP.NET Core Entity Framework with CRUD operations. I want to use Database First.
So please can someone guide me in the right path, how I can setup an ASP.NET…

Zagros
- 142
- 2
- 10
1
vote
0 answers
How to use a Database-first registered DbFunction inside another context with Linq To Entities?
I would provide an Oracle Database function (ie. RemoveDiacritics) in my low-layer C# package which is installed on multiple websites, to allow these applications to use my custom function inside their Linq To Entities queries. The goal is to…

Sackey
- 392
- 2
- 11
1
vote
1 answer
Entity Framework database first with MySQL and MS SQL
I currently have an application which uses EF database first which was built against SQL Server database. I would like to allow the ability to connect to either MSSQL or MySQL.
I assumed that by using EF I could just change the connection string to…

Omar
- 39,496
- 45
- 145
- 213
1
vote
0 answers
Add ASP.NET Core Identity to an existing project that has the database first model
I would like to add ASP.net Core Identity in an already existing project, which already has many tables mapped with database first, also I should add a relationship between AspNetUserId and my table mapped to the model with Database First
example of…

gemon01
- 181
- 7
1
vote
1 answer
EF 4.1 Code First problem with parent child and Inheritance Mapping
I have run into some problems with Inheritance Mapping, I can't get it to map correct to the base class, and get an Invalid column on all the fields in the base class (Elements)
The project wos working before we upgraded from CTP5 to 4.1 and where…

vLX
- 103
- 6
1
vote
0 answers
Firebird Entity Framework casts all string parameters to Varchar(8191)
I'm using VS2017 and Firebird as database. I use database first to create my Model from all stored procedures. When I execute a procedure, all string variables cast as CAST(@I_NAME AS VARCHAR(8191)) and when I have more than 5-6 string variable I…

Amin
- 93
- 1
- 13
1
vote
2 answers
Use "Attach" as an Upsert in Entity Framework Core
According to oneunicorn,
DbSet.Attach puts all entities in the graph into the Unchanged state. However, entities will be put in the Added state if they have store-generated keys (e.g. Identity column) and no key value has been set.
I'm having…

William Jockusch
- 26,513
- 49
- 182
- 323