Questions tagged [ef-model-first]
231 questions
8
votes
1 answer
Change Default Name of Relations
I have two tables with below structure :
*Table User*
id int identity
username varchar
role varchar
*Table Ticket*
id int identity
admin_id int
user_id int
admin_id and user_id are the foreign keys from User table.
I…

Saman Gholami
- 3,416
- 7
- 30
- 71
8
votes
3 answers
Disable the default constructor on a Database-First workflow
How can I prevent the use of the parameterless constructor of the generated DbContext?
var dcx = new DataEntities();
The default constructor is generated by the T4 template, and I thus cannot override it in a partial class. I would prefer it not…

Zev Spitz
- 13,950
- 6
- 64
- 136
8
votes
2 answers
How to avoid data loss with EF Model First database schema upgrade?
This is a long question, but I would be very very thankful if I can get some good advice on this. In short, I’m looking for a good approach for version upgrade of MS SQL database schema that also demands data being moved from deleted tables into new…

lightbricko
- 2,649
- 15
- 21
8
votes
1 answer
The entity type is not part of the model for the current context
This is a MODEL first approach. I have already researched this extensiely and have not come up with an answer. I have tried all the suggestions at the following links:
This appears to be the same problem but with no resolution
The entity type…

Aaron Bar
- 611
- 1
- 7
- 20
7
votes
3 answers
Use strong spatial types option in model designer locked?
I'm working on a model first EF6 model in model first approach.
EF exposes more than DBGeometry and DBGeography and allows me to select specific subtypes when designing the model (like GeographyPoint).
However my generated classes are still simply…

Ronan Thibaudau
- 3,413
- 3
- 29
- 78
7
votes
2 answers
Model First: how to add property of type Color?
I'm creating a new database with the model-first approach and I want to add a column to a table of the type System.Drawing.Color but I don't have this option in the properties list.
Is there a way to use more data types than the ones available?

Mihai Bratulescu
- 1,915
- 3
- 27
- 43
6
votes
2 answers
Entity framework model first timestamp
I am developing Entity Framework based app. I am using model-first approach. I would like to handle the concurrency issues. As written in many articles I am going to do it by turning the ConcurrencyMode to fixed on a field which is a timestamp. At…

rideronthestorm
- 727
- 1
- 13
- 32
6
votes
4 answers
How to run an SQL script against a MDF file?
I've created a database model with model-first method using Entity Framework 4.0. I then created an sql script using the Generate Database from Model... I've also created an SQL Server Database file in my App_Data folder. How do I now run the SQL…

gligoran
- 3,267
- 3
- 32
- 47
6
votes
3 answers
How to auto-update the Modified property on a Entity in Entity Framework 4 when saving?
Im using EF4 in VS2010, POCO's and the model-first approach.
My entity has the following properties: Id:Guid, Name:String, Created:DateTime, Modified:DateTime, Revision:Int32.
I create my entity, set the name and save it to the database using the…

Andreas Zita
- 7,232
- 6
- 54
- 115
6
votes
1 answer
ASP.NET Identity Model First fails because of renamed AspNetUserRoles columns
Like several others I have tried to implement ASP.NET Identity Model First. Everything works fine once you have tried, errored, fumed, searched and resolved.. I thought.
See also:
ASP.NET Identity with EF Database First…

JeroenW
- 753
- 6
- 16
6
votes
3 answers
What can I use instead of an Include?
Is there an alternative to using Include to eager load entities?
The reason I can't use Include is that it appears to be case sensitive.
Consider the following example:
I have two tables:
Notes the difference in case.
When I want to eager load…

Jens Kloster
- 11,099
- 5
- 40
- 54
6
votes
4 answers
EF pluralize table's name on generating database from model
I have some models and tables in EF that you can see one of those here:
Now when I want to generate database from model it adds 's' to name of tables in generated sql:
CREATE TABLE [dbo].[Options] (
[Id] int IDENTITY(1,1) NOT NULL,
[Name]…

Majid
- 13,853
- 15
- 77
- 113
6
votes
2 answers
EntitySet System.InvalidOperationException - "the entity type is not part of the model for the current context"
Similar Questions
The entity type is not part of the model for the current context -and- EF 4.1 Code First error - The entity type SomeType is not part of the model for the current context are similar questions but they are "code first"…

one.beat.consumer
- 9,414
- 11
- 55
- 98
5
votes
2 answers
Entity Framework: Model First, Inheritance?
I have a Person table, an Employee table, and a Contractor table. All Employees are people, all Contractors are people and every Person is either an employee or a Contractor. Like so:
How would I be able to accomplish this concept using Model…

dcolumbus
- 9,596
- 26
- 100
- 165
5
votes
0 answers
Entity Framework update Model without losing data while using Model first
I have seen this question a lot around here, however all the solutions involve using EF code-first. I used model-first using a designer to layout me entities and their relationships. I would like to update my production server's scheme without…

EK_AllDay
- 1,095
- 2
- 15
- 35