entity-framework-4.3.1

Entity Framework - closure of Object Contexts

£可爱£侵袭症+ 提交于 2019-12-10 14:09:55
问题 After using EFProfiler (absolutely fantastic tool BTW!) for profiling a few of our Entity Framework applications, it seems that, in most cases, all of the Object Contexts are not closed. For example, after running it locally, EF Profiler told me that there were 326 Object Context's opened, yet only 1 was closed? So my question is, should I worry about this? Or is it self-contained within Entity Framework? 回答1: If you're not using an IoC container is there anyway you can close the

How to avoid duplicate insert in Entity Framework 4.3.1

旧城冷巷雨未停 提交于 2019-12-01 11:21:50
问题 I have a small model created using code-first approach - a class City which contains only information about city name. public class City { public City() { Posts = new List<Post>(); } public City(string cityName) { Name = cityName; } public virtual ICollection<Post> Posts { get; private set; } public int Id { get; set; } public string Name { get; private set; } } A Post class represents combination of zip code and city reference public class Post { public virtual City City { get; set; } public

EF 4.3.1 and EF 5.0 DbSet.Local is slower than an actual Database query

谁说我不能喝 提交于 2019-11-30 06:15:01
I've got a database with a table of about 16,500 cities, and an EF Data Model (Database-First) for that database. I preload them into memory with the code: Db.Cities.Load() ...then when it's time to use them, I've tried each of the following queries: Dim cities() As String = Db.Cities.Select(Function(c) c.CityName).ToArray Dim cities() As String = Db.Cities.Local.Select(Function(c) c.CityName).ToArray The first query is fast (~10ms), but the second one takes about 2.3 seconds to run the first time (although it's faster than the first query when it's called after that). This doesn't make sense

EF 4.3.1 and EF 5.0 DbSet.Local is slower than an actual Database query

佐手、 提交于 2019-11-29 05:59:36
问题 I've got a database with a table of about 16,500 cities, and an EF Data Model (Database-First) for that database. I preload them into memory with the code: Db.Cities.Load() ...then when it's time to use them, I've tried each of the following queries: Dim cities() As String = Db.Cities.Select(Function(c) c.CityName).ToArray Dim cities() As String = Db.Cities.Local.Select(Function(c) c.CityName).ToArray The first query is fast (~10ms), but the second one takes about 2.3 seconds to run the first