entity-framework-4

What causes POCO proxy entities to only sometimes be created in Entity Framework 4

不羁的心 提交于 2019-12-08 05:37:59
问题 I have set up my POCOs and I have marked their public properties as virtual and I am successfully getting Proxies most of the time (95%) but randomly I am getting EF return some proxies and some non-proxies. Recycling the app pool when this happens will then fix this instance of the error and it will go away for an amount of time. Then it will re-occur in some other random (it seems) place. What can cause this sort of behaviour? alt text http://www.freeimagehosting.net/uploads/36c95af3c7.jpg

Getting an error on website when multiple users access same page simultaneoulsy

喜欢而已 提交于 2019-12-08 05:09:49
问题 I'm getting the following error message on an ASP.NET 4 website when multiple users access the same page: The underlying provider failed to open. at System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf etc...... I use Entity Framework 4 to access the SQL Server 2008 database. The page works sometimes so I know the connection string is correct. Also the Database is set to multi user and I have MARS set to true in connection string. Also in the event viewer I sometimes get the SQL

Error connecting to SQL Azure Database

会有一股神秘感。 提交于 2019-12-08 05:06:30
问题 The below error occurs often. I wonder if anyone has ever experienced this or what would be the reason? I use Entity Framework 4.0 and. NET 4.0 and Visual Studio 2010 and Windows Azure SDK 1.7 and 2.0. Below is the connection string: <add name="MyEntities" connectionString="metadata=res://*/Model.ModelMy.csdl|res://*/Model.ModelMy.ssdl|res://*/Model.ModelMy.msl; provider=System.Data.SqlClient; provider connection string=" data source=myserver.database.windows.net; initial catalog=MyDatabase;

Error:serializing Entity Framework class

二次信任 提交于 2019-12-08 03:58:26
问题 public IList<Event> SearchEvents(DateTime fromDate, DateTime toDate, int categoryId, string eventName ) { var query = context.Events.Include("City").Where(e => e.EventCategoryID == (categoryId <= 0 ? e.EventCategoryID : categoryId) && (e.StartDate.Value.Month >= fromDate.Month) && (e.EndDate.Value.Month <= toDate.Month) && ( e.StartDate.Value.Day>= fromDate.Day) && (e.EndDate.Value.Day <= toDate.Day ) && (e.StartDate.Value.Year >= fromDate.Year) && (e.EndDate.Value.Year <= toDate.Year) &&

Getting Readonly Databind using EF POCO Objects

爱⌒轻易说出口 提交于 2019-12-08 03:47:15
问题 I am using EF4 with WPF. I am databinding to the DataGrid in a Master-Detail style. Think of the Northwind Customers -> Orders -> OrderDetails. What I am finding is that when I use POCO objects, the Orders and OrderDetails grids are read-only. If I revert to using the designer generated entities they become editable. The binding XAML looks like this: <Window.Resources> <CollectionViewSource x:Key="CustomersViewSource" d:DesignSource="{d:DesignInstance my:Customer, CreateList=True}" />

What is the best implementation for changing the database schema at runtime using Entity Framework 4?

那年仲夏 提交于 2019-12-08 03:33:27
We are building an ASP.Net MVC 2 multi-tenant application on SQL Server using the "single database, separate schema" model discussed, among other places, here and here , where each tenant has one or more users and is split out with its own, tenant specific, SQL Server schema. The application is using Entity Framework 4. In order for users for different tenants to access the data in their schema, we need to be able to specify a schema when creating an entity's ObjectContext. I have seen a few references to this tool ( http://efmodeladapter.codeplex.com/ ) but (1) I would like to not have to

Help me understand entity framework 4 caching for lazy loading

一曲冷凌霜 提交于 2019-12-08 02:13:32
问题 I am getting some unexpected behaviour with entity framework 4.0 and I am hoping someone can help me understand this. I am using the northwind database for the purposes of this question. I am also using the default code generator (not poco or self tracking). I am expecting that anytime I query the context for the framework to only make a round trip if I have not already fetched those objects. I do get this behaviour if I turn off lazy loading. Currently in my application I am breifly turning

When should entity framework be used?

假装没事ソ 提交于 2019-12-08 02:05:00
问题 I'm new to Entity Framework and, of course, I have found few questions on SOF with regards to target use-cases. Let me give you some information. I'm not dealing with different database vendors or different databases; one, and only one, SQL Server 2008 and the database has less than 30 tables. Do I really need to redo things and go with Entity Framework? EDIT: Thanks to James for fixing my question. So I'm assuming using EF adds up overhead and does some work in background which I won't know.

How can I convert an EF4 Code-First ICollection to an EntityCollection?

孤街醉人 提交于 2019-12-08 01:52:36
问题 Say I have the following entity: public class Post { public int Id { get; set; } public virtual ICollection<Comment> Comments { get; set; } } When I retrieve a Post object from the database, I need to convert the Comments collection into an EntityCollection<T> so that I can check some EF4 related data about the collection, such as if the data was eager loaded or not. Unfortunately, if I try to do a direct cast from ICollection<T> to EntityCollection<T> , I get an exception due to the fact

Pluggable Conventions in Entity Framework

♀尐吖头ヾ 提交于 2019-12-08 01:46:39
问题 I am following EF Feature CTP5: Pluggable Conventions to create custom pluggable convention (in this particular case to change the precision of all decimal fields). Looks like in the latest release of EF the Add method on ConventionsConfiguraions is also "internal'. How do i add custom Pluggable Conventions now? 回答1: The feature has been removed in EF 4.1 and a possible implementation postponed to a later release: Code First customizable (pluggable) conventions are not supported. Removing the