Questions tagged [ef4-code-only]

86 questions
2
votes
1 answer

Entities Framework 4 Code First: Large model

Has anyone advice when working with large database models when using EF4 code first? Entity sets are added to the database context, but if I have 100 tables, I need to create 100 DbSets, 1 for each table: public class Customers : DbContext { …
user351178
2
votes
1 answer

Entities and multiple databases

We've got the following scenario: Central Database (replicated across multiple servers) Client Database 1 Client Database 2 The Central db has Users and Roles amongst other things The Client dbs have similar tables to each other but with some…
Basic
  • 26,321
  • 24
  • 115
  • 201
2
votes
1 answer

EF4 Code only mapping inheritance

I've got the following model and I want ShiftRequest and MissionRequest to have a single table in the DB. public class RequestBase { public int Id { get; set; } public DateTime? RequestDate { get; set; } public int…
CD..
  • 72,281
  • 25
  • 154
  • 163
1
vote
1 answer

Is it possible to map a collection of value objects with EF4.x?

I can't find a way to map a value object collection, is it possible? public class AnEntity { public int Id {get;set;} public ICollection Values {get;set;} // <-- this } Thanks, E.
Eugene Tolmachev
  • 822
  • 4
  • 14
1
vote
0 answers

EF Code-Only: Invalid object name 'dbo.BuildVersion'

I'm trying to set up an EF Code-Only scenario with the AdventureWorksLT database but it doesn't work. I have this error: Invalid object name 'dbo.BuildVersion' The error comes from an executeReader in an inner method of the EntityFramework.dll…
pellea
  • 359
  • 3
  • 21
1
vote
1 answer

Is there a "database level" method of stopping EF 4.2 adding spaces to autogenerated table and column names?

I'm using Entity Framework 4.2 in code-only "mode". I'm letting it autogenerate my database from the model. However, it's adding spaces to my table and column names based on title-casing - e.g. a CustomerOrder class is mapped to a [Customer Orders]…
1
vote
1 answer

EF Linq Query Collection with an eager loaded child-collection

I'm using EF4.1 code first, I'm trying to to create a query which returns a collection with an eager loaded child-collection. Both has to be ordered by Position and IsActive == true These Classes are mapped. public class Type { public int Id…
jani
  • 1,344
  • 1
  • 9
  • 16
1
vote
1 answer

Is there a T4 template to generate EntityTypeConfiguration from EDMX?

I'd like to go "code-only" from a mix of designer/code-first. I know it's possible to make a T4 template to generate the EntityTypeConfiguration classes and property mappings, but is there something like that already out there? "Why would you want…
James White
  • 2,062
  • 2
  • 24
  • 36
1
vote
1 answer

Fluent API, EF 4.1: a problem of inheritance and foreign key

There are several simple classes: The first class: public class User { public int UserId { get; set; } public string Username { get; set; } // ... public ICollection Topics { get; set; } } The second class: public class…
1
vote
1 answer

load partial entityset ef4

Can I load only a few properties from an Entity? As an example I have an entity with the following properties: ID DESCRIPTION HEADER PICTURE I only want to load the IDs and not the other properties. How can I do this?
maggie
  • 193
  • 16
1
vote
3 answers

Have a problem with EF 4.0 and ObjectStateManager (i think)

I have a serious problem, i have an unique key on field in db, I use Oracle(Devart Provider). First time i preform an Insert -> (_objectSet.Add(entity)) via my repository it's ok, BTW: I use Code Only model and CTP5. Then if i want to insert it…
hackp0int
  • 4,052
  • 8
  • 59
  • 95
1
vote
2 answers

Why doesn't Entity Framework add a "where" to the SQL generated when SingleOrDefault is used?

I'm using Entity Framework CTP 5 with "code only" (with SQL Server 2008). I have an entity returned from a DbContext that I then access a child collection from, and select one item from it. Here's my LINQ statement: Question currentQuestion =…
dommer
  • 19,610
  • 14
  • 75
  • 137
1
vote
1 answer

EF4 CTP5, mapping different entities to the same (existing) table

By code-first approach (but with an existing db schema), we are trying to map 2 different entities (Customer and Resource) to the same table. Both entities has the same keys and mapping. However, when running the app, we have a runtime error telling…
1
vote
4 answers

EF4, MVC 3, Azure and Code First or Traditional

I am planning to build a web application using ASP MVC3 that runs on Azure with a SQL Azure back end. I would like to use the Microsoft stack and have no plans to ever change to another stack. I am looking into the use of WCF and WF but that would…
1
vote
1 answer

Entity Framework CTP5, code-first. Nested query error

I have the following classes: public class Category { public int CategoryId { get; set; } public string Name { get; set; } } public partial class CategoryMap : EntityTypeConfiguration { public…
Andrei M
  • 3,429
  • 4
  • 28
  • 35