entity-relationship

EF Code First - Fluent API (WithRequiredDependent and WithRequiredPrincipal)

巧了我就是萌 提交于 2019-12-22 04:33:21
问题 I have the following class: public class User { public Guid Id { get; set; } public string Name { get; set; } public Couple Couple { get; set; } } public class Couple { public Guid Id { get; set; } public User Groom { get; set; } public User Bride { get; set; } } Important points: Bride and Groom properties are required One-to-one relationship In the User class, it is Couple required DbContext in OnModelCreating modelBuilder.Entity<User>().HasRequired(u => u.Couple).WithRequiredPrincipal();

ERD - How to model a relation between two entites with a third entity as “attribute”

大兔子大兔子 提交于 2019-12-21 20:44:13
问题 I'm modeling an entity relationship diagram and got stuck. I'm not sure if my considerations are wrong or an ERD can't modell what I want: I have three entities: Employee, Project and Role. There is a relation between Employee and Project: an employee is working on a project. But this employee isn't just working on this project, he/she has a field of operation that is given as a role. But isn't a relation just described by attributes? How can I make something like "An employee works on this

EF 4.1 Code First: Each property name in a type must be unique error on Lookup Table association

回眸只為那壹抹淺笑 提交于 2019-12-21 17:02:01
问题 This is my first attempting at creating my own EF model, and I'm finding myself stuck attempting to create a lookup table association using Code First so I can access: myProduct.Category.AltCategoryID I have setup models and mappings as I understand to be correct, but continue to get error 0019: Each property name in a type must be unique. Property name 'CategoryID' was already defined The following models are represented in my code: [Table("Product", Schema="mySchema")] public class Product

Entity framework POCO

孤街醉人 提交于 2019-12-21 05:10:13
问题 What does one loose by creating POCO using T4 templates in entity framework 4.0? Why is the default behavior when using entity framework 4.0 not to create POCO? 回答1: You lose a number of things. A "pure" POCO is of limited use in an ORM, because it will not do change tracking. In other words, when you mutate the object and then save changes to the context, you would like the changed properties saved to the database. With a "pure" POCO you can do this with snapshot based change tracking, which

What is the best way to represent a many-to-many relationship between records in a single SQL table?

风流意气都作罢 提交于 2019-12-21 04:54:07
问题 I have a SQL table like so: Update: I'm changing the example table as the existing hierarchical nature of the original data (State, Cities, Schools) is overshadowing the fact that a simple relationship is needed between the items. entities id name 1 Apple 2 Orange 3 Banana 4 Carrot 5 Mushroom I want to define two-way relationships between these entities so a user viewing one entity can see a list of all related entities. The relationships are defined by an end user. What is the best way to

Using Entity Framework with historical data

老子叫甜甜 提交于 2019-12-21 03:42:54
问题 I'm building a windows application in .Net 4.0 to create and organize electronics projects. The main purpose of the application is to record the vendor information for the electronics components (part #, description, price, etc.) and organize (associate) them into projects (finished products). One of the requirements is to track changes for any given vendor item (mainly price) and changes at the project level to provide a point-in-time statistics at both component level and project level

Foreign key mapping inside Embeddable class

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-21 03:42:37
问题 I am using eclipselink for JPA . I have an entity, which has a composite key fabricated out of two fields. Following is my Embeddable primary key class' fields(members). @Embeddable public class LeavePK { @ManyToOne(optional = false) @JoinColumn(name = "staffId", nullable = false) private Staff staff; @Temporal(TemporalType.TIMESTAMP) private Calendar date; //setters and getters } My entity is going to hold leave data related to a staff, so I am trying to combine staff object and leave date

How to define structure in a tag-based organization?

自作多情 提交于 2019-12-21 02:38:24
问题 [former title: Is there a way to force a relationship structure on a tag-based organizational methodology?] I have some entities, and they have a series of attributes. Some of the attributes affect what other attributes the entity can have, many of the attributes are organized into groups, and occasionally entities are requited to have certain numbers of attributes from certain groups, or possibly a range of attributes from certain groups. Is there a way to model these sorts of tag-to-tag

Entity Framework Code First Mapping

旧时模样 提交于 2019-12-21 01:39:11
问题 I have two classes, the Group class has a many to many relationship with the User class (representing the groups a user belongs to) and then the group also has a relationship of one to many with the user class (representing the owner of a group). How can I map this? public class User { public int Id { get; set; } public string Avatar { get; set; } public string Name { get; set; } public string Message { get; set; } public virtual ICollection<Group> OwnedGroups { get; set; } public virtual

Entity Framework Code First Mapping

亡梦爱人 提交于 2019-12-21 01:39:09
问题 I have two classes, the Group class has a many to many relationship with the User class (representing the groups a user belongs to) and then the group also has a relationship of one to many with the user class (representing the owner of a group). How can I map this? public class User { public int Id { get; set; } public string Avatar { get; set; } public string Name { get; set; } public string Message { get; set; } public virtual ICollection<Group> OwnedGroups { get; set; } public virtual