Questions tagged [entity-framework-ctp5]

This tag is for the ADO.NET Entity Framework Community Technical Preview 5

This tag is for the ADO.NET Entity Framework Community Technical Preview 5, released on December 6, 2010. It is a preview to Entity Framework 4.1, which focuses on "Code-First" development.

189 questions
276
votes
10 answers

How to use DbContext.Database.SqlQuery(sql, params) with stored procedure? EF Code First CTP5

I have a stored procedure that has three parameters and I've been trying to use the following to return the results: context.Database.SqlQuery("mySpName", param1, param2, param3); At first I tried using SqlParameter objects as the…
electricsheep
  • 5,114
  • 9
  • 37
  • 41
41
votes
3 answers

Refresh entity instance with DbContext

With EF4 CTP5 DbContext, what is the equivalent of this public void Refresh(Document instance) { _ctx.Refresh(RefreshMode.StoreWins, instance); } I've tried this but it doesn't do the same thing, updating the instance public…
mare
  • 13,033
  • 24
  • 102
  • 191
39
votes
2 answers

using Guid as PK with EF4 Code First

I have this class and table: public class Foo { public Guid Id {get;set;} public string Name {get;set;} } create table Foo ( id uniqueidentifier primary KEY DEFAULT (newsequentialid()), name nvarchar(255) ) the problem is that when i try to…
Omu
  • 69,856
  • 92
  • 277
  • 407
39
votes
3 answers

EF Code First - Include(x => x.Properties.Entity) a 1 : Many association

Given a EF-Code First CTP5 entity layout like: public class Person { ... } which has a collection of: public class Address { ... } which has a single association of: public class Mailbox { ... } I want to do: PersonQuery.Include(x =>…
VulgarBinary
  • 3,520
  • 4
  • 20
  • 54
35
votes
3 answers

Using Entity Framework Code First CTP5, how do I create a primary key column that are INTs and are not identity columns

Using Entity Framework Code First CTP5, how do I create a primary key column that are INTs and are not identity columns Preferably not using attributes.
ajma
  • 12,106
  • 12
  • 71
  • 90
29
votes
2 answers

Generate money type fields using code first EF CTP5

In this blog post: EF4 Code First Control Unicode and Decimal Precision, Scale with Attributes, Dane Morgridge used attributes to control the creation of different types on your database. ...And I found this pretty unique BTW!!! How do I generate…
29
votes
1 answer

EF CTP5 - Strongly-Typed Eager Loading - How to Include Nested Navigational Properties?

Attempting to cutover our EF4 solution to EF CTP5, and ran into a problem. Here's the relevant portion of the model: The pertinent relationship: - A single County has many Cities - A single City has a single State Now, i want to perform the…
RPM1984
  • 72,246
  • 58
  • 225
  • 350
25
votes
1 answer

Multi-Level Includes in CodeFirst - EntityFrameWork

It is working code; IQueryable productQuery = ctx.Set().Where(p => p.Id == id).(Include"Contexts.AdditionalProperties.Field"); But you know that it could not produce compile time error if we made mistake in string statement in…
Nuri YILMAZ
  • 4,291
  • 5
  • 37
  • 43
24
votes
3 answers

Using mvc-mini-profiler database profiling with Entity Framework Code First

I'm using the mvc-mini-profiler in my project built with ASP.Net MVC 3 and Entity Framework code-first. Everything works great until I attempt to add database profiling by wrapping the connection in the ProfiledDbConnection as described in the…
robmzd
  • 1,813
  • 3
  • 20
  • 37
22
votes
2 answers

Entity Framework: Set Delete Rule with CodeFirst

I am using EF4 CTP 5, CodeFirst. Please see my classes first: public class Guest { [Key] public Guid GuestID { get; set; } public Language PreferredLanguage { get; set; } public Guid? LanguageID { get; set;…
22
votes
3 answers

EntityFramework CTP5 DbContext T4 Template "virtual" keyword

The DbContext T4 template that comes with CTP5 does not have association fixup and not all properties are marked as virtual. Does it mean it does not support ChangeTracking when disconnected from context? First of all, does it support ChangeTracking…
learner
  • 221
  • 1
  • 5
20
votes
8 answers

Can I access the discriminator value in TPH mapping with Entity Framework 4 CTP5

Using Entity Framework 4 CTP5 Code First and this example Is it possible to access the discriminator value? I would like to use it in a projection like context.BillingDetails.Select(x => new { Number = x.Number, DiscrimitatorValue = /* how do I get…
David Glenn
  • 24,412
  • 19
  • 74
  • 94
19
votes
2 answers

Entity Framework Code First: How can I create a One-to-Many AND a One-to-One relationship between two tables?

Here is my Model: public class Customer { public int ID { get; set; } public int MailingAddressID { get; set; } public virtual Address MailingAddress { get; set; } public virtual ICollection
Addresses { get; set;…
Jeff Camera
  • 5,324
  • 5
  • 44
  • 59
14
votes
2 answers

Entity Framework Code First - Change Table Column Collation

I'm using Entity Framework CTP5 and Code First. I need to change the Collation for a specific column in SQL Server. I believe the default collation is SQL_Latin1_General_CP1_CI_AS, but I need to change this one column colllation to…
13
votes
2 answers

EF4 Code First make tables names singular

I'm using standards for singular table names. EF4 Code First has by default to pluralize table names. I have put the code to override this convention, but seems is not working. using section: using System; using System.Collections.Generic; using…
Nestor
  • 1,969
  • 4
  • 25
  • 30
1
2 3
12 13