Questions tagged [ef4-code-only]
86 questions
1
vote
0 answers
Interesting EF4 Code First Many-To-Many Relationship Question
I have two models, a Report:
public class Report
{
public int Id { get; set; }
public string Name { get; set; }
public virtual ChargeType ChargeTypes { get; set; }
}
public class ReportConfiguration : EntityConfiguration
{
…

shuniar
- 2,592
- 6
- 31
- 38
1
vote
1 answer
Code-First: How to create a many to many relationship where the source class/table is the target one as well?
Can someone please post an example on how to create a many to many relationship where the source class is also the target one, using code-first ?
Something like:
Toys * <-----> * Toys
Thank you.
Nuno Senica

csharpnet
- 45
- 4
1
vote
1 answer
How do I recreate DB using EF4 code first for test
I'm using Entity Framework 4 Code First in my .net MVC 2.0 project and I'm having hard times to get my DB sync with my Entities. What I want is a page that I can call, as an exemple : /DB/Recreate, that would drop my current DB and recreate an empty…

VinnyG
- 6,883
- 7
- 58
- 76
1
vote
1 answer
EF4 Code Only + Ria Services
I thought I could use my DbContext with a DomainService just the same way I use it with any MVC app:
public class DatabaseContext : DbContext
{
public DbSet Users { get; set; }
}
public class UserDomainService : DomainService
{
…

Ismael
- 361
- 3
- 9
1
vote
2 answers
Change model after database is created on EF4 code only
Hey, sorry for my bad english...
Using EF4 code-only, I have created some POCO classes and my database was generated from that. All worked fine, I inserted some data on the tables but now I need to create a new property on one of my classes. If i…

Leo
- 7,379
- 6
- 28
- 44
1
vote
1 answer
Base Types with EntityFramework CodeOnly
I am having a lot of trouble with 'base types' in the Code Only model of the Entity Framework. I am having a lot of trouble with 'base types' in the Code Only model of the Entity Framework.
When I try to run this code using a DbContext with a…

Ciel
- 17,312
- 21
- 104
- 199
1
vote
1 answer
EF4 Builder.Configurations - Unable to infer a key for entity type
I wonder if someone can help me.
I'm using VS2010, .Net 4, EF4 and I'm trying to generate an objectcontext which is configured entirely in code (code-only as opposed to model-first or db-first).
In short, I do:
Create a ContextBuilder
Configure…

Basic
- 26,321
- 24
- 115
- 201
1
vote
1 answer
EF4 CodeFirst CTP4 - Insert with existing association
If I have an entity that has an association (e.g. Book.Publisher), how do I save a new Book and associate it with an existing Publisher?
BTW I don't want to expose FK associations (i.e. PublisherId) in my model.
I had been using something like…

Paul Hiles
- 9,558
- 7
- 51
- 76
1
vote
2 answers
Obtaining List of Entities in DataContext
What would be the best way to obtain the list of entities loaded in a given EF 4.1 DbContext? I have been unsuccessful in attemps to locate a collection of DbEntityEntry.Entity objects loaded for a given context. It seems like it should be possible…

Jakkwylde
- 1,304
- 9
- 16
0
votes
1 answer
Get list of changed properties on EF 4.2 Code Only
(sorry for my bad english)
Hey, I need to log all changes that happens on my database for auditing purposes. When I insert or delete a entity, it is easy but when I update something, I need to save what properties have changed and from/to what…

Leo
- 7,379
- 6
- 28
- 44
0
votes
1 answer
EF Code Only Inheritance on the client
(sorry for my bad english)
In a Silverlight 4 + RIA Services + EF4 Code Only application I have some classes on my DbContext that contain a "IsActive" field - I want to know from the client if a entity have this field and get it. My first thought…

Leo
- 7,379
- 6
- 28
- 44
0
votes
2 answers
How to add entity to multiple tables?
I have 2 tables in my DB: Students and StudentsHistory. The idea is that every change in the Students table must create a new record in the StudentsHistory table (e.g. when I edit a student, 2 operations must be performed: UPDATE on Students and…

Darmak
- 905
- 2
- 11
- 16
0
votes
1 answer
WCF Data Service and Entity Framework proxy objects
I have a question regarding WCF DataService and Entity Framework 4.1 (code-first).
So I have a DataService on web server:
[ServiceBehavior(IncludeExceptionDetailInFaults = true)]
[AspNetCompatibilityRequirements(RequirementsMode =…

DolceVita
- 2,090
- 1
- 23
- 35
0
votes
1 answer
EF 4.1 Code First adding to a foreign key collection
If I have an entity with a collection property for another entity. What is the best way to add a new entity and it's related entities? The problem I have is that the collection is initially null.
var form = new Form()
{
…

JasonBSteele
- 11
- 1
0
votes
1 answer
EF4 test if collection or related entity is proxy for self-tracking entities
All,
I'm starting out with Entity Framework 4 (not CTP5 yet) and am looking at the complexities of migrating NHibernate to EF.
Some code we have tests if a collection or related entity is a proxy and, if so, performs some different code to normal.…

GrahamB
- 1,368
- 15
- 35