Questions tagged [ef4-code-only]

86 questions
6
votes
1 answer

Junction table with additional columns in EF4 CTP4 Code First

Given this sql schema: create table [dbo].[Courses_Students] ( [DummyColumn] [int] null, [CourseId] [int] not null, [StudentId] [int] not null, primary key ([CourseId], [StudentId]) ); How do I define the composite primary key and…
Ismael
  • 361
  • 3
  • 9
5
votes
1 answer

How to accept JSON in a WCF DataService?

I'm trying to understand how to use WCF Data Services (based on EF 4.1) to create a restful web service that will persist entities passed as JSON objects. I've been able to create a method that can accept a GET request with a set of primitive data…
codemonkey
  • 1,213
  • 2
  • 14
  • 31
5
votes
2 answers

Entity Framework CTP 5 One to One mapping

I have two tables: Requirement RequirementId - PK Fixture FixtureId - PK RequirementId - FK / NULLABLE / Unique Constraint A Fixture can only have 1 Requirement, no other Fixture should be able to reference the same Requirement. It is not mandatory…
4
votes
1 answer

How to manage EF 4.2 associations in WCF based scenarios

I am working on an enterprise application which will consist of a rich WPF client which talks to a bunch of webservices to retrieve data. This data are POCOs, created with Code First EF 4.2. I am now facing a conceptual problem which i have been…
user604613
4
votes
2 answers

Data Loading Strategy/Syntax in EF4

Long time lurker, first time posting, and newly learning EF4 and MVC3. I need help making sure I'm using the correct data loading strategy in this case as well as some help finalizing some details of the query. I'm currently using the eager loading…
4
votes
2 answers

How can I map an array property to a delimited string db field using EF?

I have an object with an array property that I want to persist in the database as a delimited string. How to I Map that property to the field in the database and vice versus? public class User() { public int Id { get; set; } public string[]…
jedatu
  • 4,053
  • 6
  • 48
  • 60
4
votes
3 answers

MVC, ViewModels, and Validation

I'm creating an MVC3 application with EF4 using POCOs. I've added validation attributes to my EF entities. Now, as I'm building the views, I want to use a view model (and perhaps use AutoMapper to fill them). The problem that I have run into is…
Brian
  • 37,399
  • 24
  • 94
  • 109
4
votes
1 answer

Entity Framework 4 Code Only Get table name from MetaData for POCO domain object

Hi I am using Entity Framework code only from CTP4. My question is this: given the name of a domain class which is mapped using an EntityConfiguration how can I retrieve the table name for the mapped class at runtime? I'm assuming I need to be…
Raoul
  • 2,043
  • 1
  • 21
  • 29
3
votes
1 answer

EF4 code first many to many relationship to external entity

Problem I've got two classes: OfficeProfile: exists within my EF model BusinessUnit: comes from an external source, e.g. a web service There is a many to many relationship between office profiles and business units, which I'd like to represent in…
3
votes
2 answers

entity framework 4.1 code first and auto mapper issue

Consider this simple Model and ViewModel scenario: public class SomeModel { public virtual Company company {get; set;} public string name {get; set;} public string address {get; set;} //some other few tens of properties } public…
Jaggu
  • 6,298
  • 16
  • 58
  • 96
3
votes
5 answers

Code-First EF4.1 + SQL Server CE4 + Sync Framework

Is it possible to use CF EF4.1, SQL Server Compact 4 and Microsoft Sync Framework together? As I got, MS Sync Framework needs SQL Server compact 3.5, but EF4.1 use SQL Server Compact 4... UPDATE Ok, I see that it's not possible to sync mssql ce4…
3
votes
1 answer

Mocking DbEntityEntry.CurrentValues.SetValues() in EF4 CTP5 Code First

I am trying to use the DbEntityEntry.CurrentValues.SetValues() method to facilitate updating an existing entity with values from a non-entity DTO (see:…
Steve
  • 31
  • 3
3
votes
2 answers

EF4 CodeFirst CTP5 nvarchar(max) via attribute

Is there a way to create a custom attribute that will make EF CodeFirst use nvarchar(max) as datatype when assigned to a property of a poco class? I know this is possible via fluent api, but we would like to have all definitions within one place and…
3
votes
1 answer

EF4 CTP5 - HasColumnType not working

I want to override the default nvarchar(4000) for one of my string columns to a text data type in SQL Express. I use this code. modelBuilder.Entity() .Property(p => p.Information) …
Daveo
  • 19,018
  • 10
  • 48
  • 71
3
votes
3 answers

How do I split a table into multiple types in EF4 code first?

I am using code-first POCOs with EF4, CTP5. I've got a table with a lot of columns in it (over 100). I want to split the table into multiple types (aka "Table Splitting") so that I don't have to fetch all the data every time I want some basic…
Brian
  • 37,399
  • 24
  • 94
  • 109