entity-framework-4.1

DbContext ChangeTracking kills performance?

僤鯓⒐⒋嵵緔 提交于 2020-01-10 07:53:20
问题 I am in the process of upgrading an application from EF1 to EF4.1 I created a DbContext and a set of POCOs using the "ADO.NET DbContext Generator" templates. When I query the generated DbContext the database part of the query takes 4ms to execute (validated with EF Profiler). And then it takes the context about 40 seconds (in words: FORTY!) to do whatever it does before it returns the result to the application. EF1 handles the same query in less than 2 seconds. Turning off AutoDetectChanges,

DbContext ChangeTracking kills performance?

情到浓时终转凉″ 提交于 2020-01-10 07:53:12
问题 I am in the process of upgrading an application from EF1 to EF4.1 I created a DbContext and a set of POCOs using the "ADO.NET DbContext Generator" templates. When I query the generated DbContext the database part of the query takes 4ms to execute (validated with EF Profiler). And then it takes the context about 40 seconds (in words: FORTY!) to do whatever it does before it returns the result to the application. EF1 handles the same query in less than 2 seconds. Turning off AutoDetectChanges,

Entity Framework Database.SetInitializer simply not working

帅比萌擦擦* 提交于 2020-01-09 03:33:04
问题 I am having this kind of "mysterious" issue here. I am currently using Entity Framework 4.1 Code First approach with my ASP.NET MVC 3 application, it worked great, until yesterday... Something really bad happened that caused my Database.SetInitializer to stop working. Explained: I have this simple model public class User { public int Id { get; set; } public int RoleId { get; set; } [Required] [StringLength(50)] [DataType(DataType.Text)] public string Login { get; set; } [Required]

Entity Framework - implementing IDbSet

风流意气都作罢 提交于 2020-01-06 08:21:29
问题 I would like to implement IdbSet to provide my DbContext a custom implementation that will essentially serve to filter my data for the currently logged in user (I am working on a multi-tenant application). The general idea I am going with is very similar to this post: Can a DbContext enforce a filter policy? However, it is not clear to me how to make DbContext "know" about how to use my own class that implements IDbSet. I am having a tough time finding documentation on this. Any pointers

Entity Framework 4.1 Code First - Keys/Navigation Properties

柔情痞子 提交于 2020-01-06 08:17:13
问题 Is this how you would setup a basic PK/FK relationship? Do you have to define both the key and the navigation property? Public Class Foo 'PK Public Property FooID As Integer 'Navigation Prop Public Overridable Property Bars As ICollection(Of Bar) End Class Public Class Bar 'PK Public Property BarID As Integer 'FK Public Property FooID As Integer 'Navigation Prop Public Overridable Property Foo As Foo End Class 回答1: This is basic configuration if you want default conventions to take care of

WCF, Entity Framework 4.1 and Entity's State

☆樱花仙子☆ 提交于 2020-01-06 05:39:06
问题 I am developing an application which will expose WCF services. I am using Entity Framework 4.1 at the DAL. The problem is when I load some entity (let say a Customer that has Order which in turn has OrderDetail). After loading it I make some changes in Customer, Order and OrderDetail objects (some new orders are added and some existing orders are removed/updated) and send the object graph to WCF service to update it as following. Customer oCustomer; using(var context = new MyContext) /

Custom non-primitive type in Entity Framework code-first 4.1

陌路散爱 提交于 2020-01-05 08:07:27
问题 I have this custom type: public struct PasswordString { private string value; public PasswordString(string value) { this.value = MD5.CalculateMD5Hash(value); } public string Value { get { return this.value; } set { this.value = MD5.CalculateMD5Hash(value); } } public static implicit operator PasswordString(string value) { return new PasswordString(value); } public static implicit operator string(PasswordString value) { return value.Value; } public static bool operator ==(string x,

Unobtrusive Oracle Deployment on Windows Server 2008

别说谁变了你拦得住时间么 提交于 2020-01-04 11:47:06
问题 I have a .NET 4.0 Web Forms app that I am running with the beta Oracle EF-aware data provider, and I want to perform "unobtrusive" Oracle deployment to a Win2K8 box, as shown in many SO solutions. There is an existing Oracle Instant Client installation on the Win2K8 box, which I can neither work with nor remove, and it has an entry in the PATH environment variable on the Win2K8 box. According to this SO answer, I do not need to set PATH for my Oracle DLLs, since I have DllPath set in the web

Unobtrusive Oracle Deployment on Windows Server 2008

三世轮回 提交于 2020-01-04 11:46:09
问题 I have a .NET 4.0 Web Forms app that I am running with the beta Oracle EF-aware data provider, and I want to perform "unobtrusive" Oracle deployment to a Win2K8 box, as shown in many SO solutions. There is an existing Oracle Instant Client installation on the Win2K8 box, which I can neither work with nor remove, and it has an entry in the PATH environment variable on the Win2K8 box. According to this SO answer, I do not need to set PATH for my Oracle DLLs, since I have DllPath set in the web

Unobtrusive Oracle Deployment on Windows Server 2008

房东的猫 提交于 2020-01-04 11:44:47
问题 I have a .NET 4.0 Web Forms app that I am running with the beta Oracle EF-aware data provider, and I want to perform "unobtrusive" Oracle deployment to a Win2K8 box, as shown in many SO solutions. There is an existing Oracle Instant Client installation on the Win2K8 box, which I can neither work with nor remove, and it has an entry in the PATH environment variable on the Win2K8 box. According to this SO answer, I do not need to set PATH for my Oracle DLLs, since I have DllPath set in the web