entity-framework-4

Entity Framework Designer Errors

北城以北 提交于 2019-12-11 03:35:43
问题 I have created a project is Visual Studio 2012 and have set up Entity framework through "Database First" approach. However after mapping to the database and generating my Designer.cs file which is supposed to be automatically generated by the framework, I end up with heaps of errors which I can't get where they come from. I have attached the error as a txt file for your review and professional comment. Please take note that I'm new to the .net framework, specially the EF area. So I'd

Finding the related FK property of a Navigation Property

删除回忆录丶 提交于 2019-12-11 03:34:38
问题 At run time I would like to find whether an EntityObject also has a foreign key property for a given NavigationProperty. I have this in two steps below. I imagine this is going to require some metadata querying. I am unsure how to test whether a metadata class points to the type of a particular EntityObject type: ie I know conceptually but not programmically the relationship between an EntityType instance and an EntityObject instance. So far I have: /*puesdo code class representing edm

Raise PropertyChanged on custom properties in EntityObject

不想你离开。 提交于 2019-12-11 03:27:00
问题 I have several custom calculated properties on an EntityObject. I would like to fire the PropertyChanged event to notify all bindings. This does not work however, and it throws an argumentexception when I use ReportPropertyChanged: De eigenschap Name heeft geen geldige entiteitstoewijzing op het entiteitsobject. Zie de documentatie van Entity Framework voor meer informatie. Which means than Name is not an entity property and I should look in the Entity Framework documentation for more

Split a entity collection into n parts

ⅰ亾dé卋堺 提交于 2019-12-11 03:15:04
问题 I have a database table. First, I want to group by date time. Then I want to only select the groups with n items. My class looks like this: public class VisitDate { public int Id {get;set;} public int VisitMeDate {get;set;} ..... ..... } My SQL table is like below: Id Date --- ----------------------- 136 2012-05-09 10:00:00.000 167 2012-05-09 12:00:00.000 137 2012-05-10 10:00:00.000 168 2012-05-10 12:00:00.000 194 2012-05-10 14:00:00.000 138 2012-05-11 10:00:00.000 169 2012-05-11 12:00:00.000

Why does disabling lazy loading cause related tables to have no results?

亡梦爱人 提交于 2019-12-11 03:08:33
问题 Given: public SomeEntity Read(int primaryKey) { SomeEntity myEntity; using (var context = new MyEntities2()) { context.Configuration.LazyLoadingEnabled = false;//This line is wacky myEntity = context.SomeEntities.SingleOrDefault(ct => ct.PrimaryKey == primaryKey); if (myEntity == null) return myEntity; //Force eager Load... var bypassDeferredExecution = myEntity.RelatedTable1.ToList(); var bypassDeferredExecution2 = myEntity.RelatedTable2.ToList(); } return myEntity; } If I set

Entity Framework 4, TPH (Table Per Hierarchy) and annotation

泪湿孤枕 提交于 2019-12-11 02:56:23
问题 I currently try to migrate an application of mine from datasets to EF4. So I have an existing database. One of the tables is mapped to 2 classes, depending of the value of a column. So I am in a TBH schema with an existing table and an existing discriminator. Is there a way to discribe this using annotations ? thanks 回答1: No. TPH discriminator can be controlled only through Fluent-API. 来源: https://stackoverflow.com/questions/10014410/entity-framework-4-tph-table-per-hierarchy-and-annotation

How to filter entities that are deleted using linq to entities

ⅰ亾dé卋堺 提交于 2019-12-11 02:45:21
问题 I have a singleton DBContext but for some reason when the instance is shared across 2 methods does not populate the changes made in other method. Eg: Method1Delete2RowS() will delete 2 rows. Method2() reads all rows that are not deleted My method 2 always shows deleted records too. Cause i have not accepted any changes yet. I used something like this context.Students.Where(x => context.ObjectStateManager.GetObjectStateEntry(x) .State != System.Data.EntityState.Deleted); but this code throws

Entity Framework 4.1 - Select

旧时模样 提交于 2019-12-11 02:42:23
问题 I am using the following expressions: ProductRepository.Query.Include(Function(x) x.ChildProducts.Select(Function(y) y.PriceTiers.Where(Function(z) z.IsActive))).Where(Function(x) x.Categories.Any(Function(y) y.ID = ID)) And getting this error: The Include path expression must refer to a navigation property defined on the type. Use dotted paths for reference navigation properties and the Select operator for collection navigation properties. If I remove this: .Where(Function(z) z.IsActive) It

DbEntityValidationException After Upgrading to EF 4.1

旧巷老猫 提交于 2019-12-11 02:37:40
问题 Today I decided to upgrade to EF 4.1 (from CTP5). I am using Code First. Unfortunately, whenever I try to run the project I get this exception: System.Data.Entity.Validation.DbEntityValidationException: Validation failed for one or more entities. See 'EntityValidationErrors' property for more details. The EntityValidationErrors property doesn't really say anything about the entities that are causing the exception. Nether does the Stack Trace actually. But, the exception is thrown on the line

Is there a way to selectively skip silverlight field validation when using wcf ria?

拟墨画扇 提交于 2019-12-11 02:06:48
问题 I have a (likely common) case where I would like to reuse the same class for both adding a new entity and editing an existing entity in my silverlight app (SL4, WCF RIA, EF4, Linq-to-Entities). When adding a new one, I would like my custom validator to check for uniqueness and fail if it's not unique. However, when editing, I don't want that same validator to prevent edits. Is there a way to temporarily turn off validation for a single field (ideally by validation type so that the other