entity-framework-4

Error 3004, mapping error with EF

谁说我不能喝 提交于 2019-12-23 08:47:56
问题 Ok since my of my issues have been resolved,I was flying through the code, until now: I've now run into one I cant even find anything on Google for it. Here's the text of the error: Error 3004: Problem in mapping fragments starting at line 937:No mapping specified for properties StoreItem.ItemPrice in Set StoreItems. An Entity with Key (PK) will not round-trip when: Entity is type [psychoco_GodsCreationTaxidermyModel.StoreItem] F:\Projects\GodsCreationTaxidermySVN\GodsCreationTaxidermy.Data

Entity Framework and DbSet

馋奶兔 提交于 2019-12-23 08:04:40
问题 I am trying to set up a generic interface to retrieve entities from a repository. The problem is that I need to request data from a WCF service and Generics don't work with operation contracts, from what I can see. So I have this which works in a console application, not using a service call: public virtual List<T> GetAll<T>() where T : MyBaseType { return this.datacontext.Set<T>().Include(l => l.RelationshipEntity).ToList(); } The only way I could see dong this would be something like:

Entity Framework and DbSet

送分小仙女□ 提交于 2019-12-23 08:04:33
问题 I am trying to set up a generic interface to retrieve entities from a repository. The problem is that I need to request data from a WCF service and Generics don't work with operation contracts, from what I can see. So I have this which works in a console application, not using a service call: public virtual List<T> GetAll<T>() where T : MyBaseType { return this.datacontext.Set<T>().Include(l => l.RelationshipEntity).ToList(); } The only way I could see dong this would be something like:

Upgrade to EF 6.1.1 makes effect of [NotMapped] disappear

我的梦境 提交于 2019-12-23 07:57:18
问题 I have upgraded from EF 4.3.1 to 6.1.1 and now it seems like the annotation [NotMapped] is useless. Yes, i have change to correct assembly and everything looks fine on compilation. Everywhere where [NotMapped] is present the property is handled as a domain property and i get an error that EF can't find the matching column in database. Example: private bool _authenticated = true; [NotMapped] public bool Authenticated { get { return _authenticated; } set { _authenticated = value; } } Yes, it

Upgrade to EF 6.1.1 makes effect of [NotMapped] disappear

喜夏-厌秋 提交于 2019-12-23 07:57:16
问题 I have upgraded from EF 4.3.1 to 6.1.1 and now it seems like the annotation [NotMapped] is useless. Yes, i have change to correct assembly and everything looks fine on compilation. Everywhere where [NotMapped] is present the property is handled as a domain property and i get an error that EF can't find the matching column in database. Example: private bool _authenticated = true; [NotMapped] public bool Authenticated { get { return _authenticated; } set { _authenticated = value; } } Yes, it

Entity Framework 4.0 GetChanges() equivalent

試著忘記壹切 提交于 2019-12-23 07:44:40
问题 In LINQ to SQL, you can override SubmitChanges and use the method this.GetChangeSet() to get all the inserts, updates and deletes so that you can make last minute changes before it is committed to the database. Can this be done in EF 4.0? I see there is a override for SaveChanges but I need to know the equivalent for GetChangeSet() 回答1: Found it. ObjectContext.ObjectStateManager.GetObjectStateEntries(System.Data.EntityState.Added); for inserts. 来源: https://stackoverflow.com/questions/2928500

Code First - UML - Modeling of database - visual view possible?

依然范特西╮ 提交于 2019-12-23 06:04:11
问题 I love how model first gives a visual overview of the database. But now the Ado.Net team pushes code first, i'd think it would be awesome to generate an UML overview of the database through your classes. Does this already exists? As i can't seem to find it :( 回答1: Yes it exists as part of EF Power Tools CTP1 where you can generate read-only EDMX from your code first mapping. It is not UML but it is the same diagram you had with model first. 回答2: UML is representing an object approach while

Entity Framework - 1 to 1 relationship where one end is not a primary key

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-23 05:42:17
问题 I'd like to define a relationship in an Entity Framework data model that is 1-to-1 with one end as a primary key of one table and the other end a foreign key on another. For instance: table: aspnet_Users w/ col: UserId guid Primary Key with the UserId property of the aspnet_Users table related to the AspUserId column of the User table: table: User w /col: UserId int Primary Key w /col: AspUserId guid When I try to do this I get an error saying that since the AspUserId field is not a primary

How to load nested Entity Framework objects efficiently

不想你离开。 提交于 2019-12-23 04:54:16
问题 I'm trying to load a 3-deep tree into a treeview control using entity framework Categories, SubCategories and Products in the code below categories is an IQueryable<ProductCategory> where ProductCategory is an EF4.0 generated object (default code generation) SubCategories is a FK back to the categories table (so in theory we could go to any depth, but the data domain will only have two levels) var container = categories.Where(c=>c.somecondition).Include("Subcategories.Products"); foreach (var

Entity Framework 4 CTP 5 POCO - How to Unit Test my Repository<T>

◇◆丶佛笑我妖孽 提交于 2019-12-23 04:48:08
问题 This is the 2nd part of another question Entity Framework 4 CTP 4 / CTP 5 Generic Repository Pattern and Unit Testable), where I asked how to implement a generic repository pattern using EF 4 POCO. Now that my repository is working, I would like to know how to unit test my Repository (TDD or BDD). Thanks all. 回答1: Hey I wrote some blog posts on doing this with SpecFlow. But that was a disaster when it got complex. I tried to implement a testing repository which was also a disaster. Trying to