Mappings used between tables and classes in Entity Framework
Questions tagged [entity-framework-mapping]
40 questions
15
votes
3 answers
ASP.NET EF remove discriminator column from not mapped class
I have a model of my content:
class BaseModel {
public virtual string Content{ get; set; }
// ...
}
To display the data only the model above is fine. But I want to add the functionality to edit the content. So I need to add an attribute to…

Lion
- 16,606
- 23
- 86
- 148
13
votes
2 answers
Why does the `DatabaseGeneratedOption.None` exist?
This is used with the Property(() => p).HasDatabaseGeneratedOption() call. Is is perhaps to turn off default DB value generation?

ProfK
- 49,207
- 121
- 399
- 775
8
votes
1 answer
EntityFramework 5 Code First multiple inheritance mapping (TPC)
All right, probably this question has been answered before but I have been researching and I just can not find the solution to my specific problem
Code of this sample - Visual Studio 2012 - Console App
So I have an EntityFramework Code First model…

Jupaol
- 21,107
- 8
- 68
- 100
7
votes
1 answer
EF 6 - Cascade Delete on one to many without backreference
I have something like this:
public class Gadget {
public int Id { get; set; }
public string Name { get; set;}
public int SuperHeroId { get; set; }
}
public class SuperHero {
public int Id { get; set; }
public virtual ICollection…

George Mauer
- 117,483
- 131
- 382
- 612
5
votes
1 answer
EF Code First, map two navigation properties to the same object type
If I have a User class that has these properties:
public Guid UserPreferenceId { get; set; }
public virtual DefaultUserPreference UserPreference { get; set; }
public Guid SecondaryUserPreferenceId { get; set; }
public virtual…

SventoryMang
- 10,275
- 15
- 70
- 113
5
votes
1 answer
What is the best way to re-name a column in edmx?
I am using entity framework 4.0 my approach is Database first approach. what is the best way to rename a column name or change the data type of column in edmx.
thanks in advance.

sumanth
- 65
- 6
4
votes
1 answer
do we need to an id always while creating a hibernate entity? even if I am creating an entity from a view?
I am using MySQL 5.5 and hibernate 3. I have created a view in my database and also created an entity corresponding to it using salto db generator. When I try to execute my code the bean creation for session factory fails giving me the following…

Shreyash
- 367
- 1
- 3
- 11
3
votes
3 answers
Two entities with possibly different keys are mapped to the same row
I have Table
Field1 PK int not null
Field2 PK int not null like this
when i want to map this table I get this error
Error 3 Error 3034: Problem in mapping fragments starting at lines 2212, 2218:
Two entities with possibly different keys are…

saulyasar
- 797
- 1
- 17
- 45
3
votes
1 answer
EntityFramework - many-to-many reference in the DB without a backreference in the model
In my application users can define Parameters, and then create SlideSets based on a grouping of parameters.
I am using code-first Entity Framework 5.0 and I have the following model:
class SlideSet {
public ICollection…

George Mauer
- 117,483
- 131
- 382
- 612
3
votes
2 answers
How to disable automapping of properties in Entity Framework
I've decided to use fluent mapping in Entity Framework. My intention was to map everyting by code without any atributes and auto mapping functions. Best way I've found is class EntityTypeConfiguration, that I implement for each entity in my project.…

user1859898
- 41
- 4
3
votes
2 answers
Override DbContext SaveChanges
I use EF 4.3.1 I need adding a Default Value of an entity at the moment of saving.
At the moment I'm using SaveChanges() and it works.
As you can see from the code I use ChangeTracker.Entries

GibboK
- 71,848
- 143
- 435
- 658
2
votes
2 answers
Entity Framework getting a ICollection from mapper
using Entity Framework 4.1 trying to get a collection of ints,
basically I have a Entity called Spec
public class Spec {
public int Id{get;set;}
public string Name {get;set;}
public ICollection TypeIds {get;set;}
}
the table Specs…

Bob The Janitor
- 20,292
- 10
- 49
- 72
2
votes
1 answer
Entity Framework One To required Many mapping not working
I have two classes, with a 1 - 1..* relationship.
class A
{
public long Id;
public virtual ICollection Bees;
}
class B
{
public long Id;
public A MyA;
}
Now, I'm trying to get my database to behave so that any instance of A has…

yesman
- 7,165
- 15
- 52
- 117
2
votes
2 answers
Merging two Query Results
I have following two Queries on Same Table and need to merge it.
var Prod = this.UnitOfWork.myRepository.GetData();
var PreProd = this.UnitOfWork.myRepository.GetData();
var Merge = Prod.Union(PreProd);
But when i check results of Merge it…

InTheWorldOfCodingApplications
- 2,526
- 6
- 46
- 87
2
votes
0 answers
Pre compiled views are not working
I was trying to use pre-compiled views for good performance, i generated the views successfully and everything is same in compile time and at run time .edmx. Earlier there was mismtach of data provider for default connection factory, .edmx always…

Yogesh
- 3,044
- 8
- 33
- 60