entity-framework-5

Azure Worker Role Asynchronous Receive message: how long I should put the sleep for? (milliseconds)

不问归期 提交于 2020-01-06 07:26:35
问题 Sample code here public override void Run() { while (true) { IAsyncResult result = CUDClient.BeginReceive(TimeSpan.FromSeconds(10), OnMessageReceive, CUDClient); Thread.Sleep(10000); } } I have tested this Azure worker role. I kept 100 messages in the Service bus Queue. It's doing entities updates as a operation(Entity framework). It took 15 minutes to process all the queues and looks like taking longer time. Any suggestion to improve this? Thanks in Advance 回答1: Try this one... /

Convention for DatabaseGeneratedOption.None

风格不统一 提交于 2020-01-05 12:30:33
问题 I would like to manually insert id for all my entities. Is it possible to create some kind of convention or I have to set HasDatabaseGeneratedOption(DatabaseGeneratedOption.None) (or add DatabaseGenerated attribute) for every entity ? EDIT There is a simpler way to do this then using accepted answer: modelBuilder.Conventions.Remove<StoreGeneratedIdentityKeyConvention>(); 回答1: It's possible to create custom conventions in EntityFramework 6 as follows: Create a convention class public class

Code First - Retrieve and Update Record in a Transaction without Deadlocks

瘦欲@ 提交于 2020-01-05 10:24:41
问题 I have a EF code first context which represents a queue of jobs which a processing application can retrieve and run. These processing applications can be running on different machines but pointing at the same database. The context provides a method that returns a QueueItem if there is any work to do, or null, called CollectQueueItem . To ensure no two applications can pick up the same job, the collection takes place in a transaction with an ISOLATION LEVEL of REPEATABLE READ . This means that

Entity framework, referential integrity constraint violation occurred error on updating entity from disconnected area

北城余情 提交于 2020-01-04 13:36:27
问题 I have below model public class Order { [Key] public virtual string OrderNo {get;set;} public virtual IList<OrderItem> Items {get;set;} } public class OrderItem { [Key] public virtual string ItemNo {get; set;} public virtual string ParentItemNo {get;set;} public virtual string OrderNo {get;set;} public virtual OrderItem ParentItem {get;set;} public virtual IList<OrderItem> ChildItems {get;set;} public virtual IList<ItemProperty> ItemProperties {get;set;} public virtual Order Order {get;set;}

Update DbSet.Local after row deletion in the database

南笙酒味 提交于 2020-01-04 04:02:16
问题 I have a DbSet associated to a DbContext (with Entity Framework 4.3). The DbSet is initially loaded with all the entities of a given table X The problem is that I'm not able to Reload the DbSet to get a frech list of the table X after the deletion of one or several rows of that table (deletion done by another DbContext in another application). Here is the line I'm using to reload all the entities of my table: ((IObjectContextAdapter) context).ObjectContext.Refresh(RefreshMode.ClientWins, col)

Update DbSet.Local after row deletion in the database

雨燕双飞 提交于 2020-01-04 04:02:10
问题 I have a DbSet associated to a DbContext (with Entity Framework 4.3). The DbSet is initially loaded with all the entities of a given table X The problem is that I'm not able to Reload the DbSet to get a frech list of the table X after the deletion of one or several rows of that table (deletion done by another DbContext in another application). Here is the line I'm using to reload all the entities of my table: ((IObjectContextAdapter) context).ObjectContext.Refresh(RefreshMode.ClientWins, col)

SelectMany makes too many queries

纵然是瞬间 提交于 2020-01-03 22:05:12
问题 I have dynamic fields inside usergroups and I want to select them based on what usergroups user is. Basically I want to simulate query like .Where(x => x.UserGroupId == x || ... because otherwise it makes about 20 queries just to get dynamicfields. Maybe I can somehow pass array of integers as UserGroupId and it will simulate the query with || . Here is my example, both results output is same, only difference is that first one has 20 queries to database and second has only 1. public

SelectMany makes too many queries

女生的网名这么多〃 提交于 2020-01-03 22:03:52
问题 I have dynamic fields inside usergroups and I want to select them based on what usergroups user is. Basically I want to simulate query like .Where(x => x.UserGroupId == x || ... because otherwise it makes about 20 queries just to get dynamicfields. Maybe I can somehow pass array of integers as UserGroupId and it will simulate the query with || . Here is my example, both results output is same, only difference is that first one has 20 queries to database and second has only 1. public

Does the new Migrations feature of Entity Framework 5 fully support enum changes?

浪子不回头ぞ 提交于 2020-01-03 07:20:10
问题 Let's say we have the following simple model: public class Car { public int Year { get; set; } public string Make { get; set; } public string Model { get; set; } public CarType Type { get; set; } } public enum CarType { Car, Truck } Entity Framework, when adding a new Car object to the database, will store the CarType enum value as an integer. If we change the CarType enum in a way where the integer values change (change the order or add/remove values), does Entity Framework know how to

EF - One to one relationship

半腔热情 提交于 2020-01-03 06:06:19
问题 I have the following class: public class FinanceiroLancamento { /// <summary>Identificação</summary> public override int Id { get; set; } /// <summary>Financeiro caixa</summary> public FinanceiroLancamentoCaixa FinanceiroLancamentoCaixa { get; set; } } public class FinanceiroLancamentoCaixa { /// <summary>Identificação</summary> public override int Id { get; set; } /// <summary>Identificação do lançamento financeiro</summary> public int IdFinanceiroLancamento { get; set; } } When I try to map