navigation-properties Questions

5

Solved

I have the next enitities: public class MyEntity { public virtual int Id { get; set; } public virtual MySecondEntity SecondEntity { get; set; } } public class MySecondEntity { public virtual in...
Muddleheaded asked 5/2, 2014 at 16:34

4

Solved

I was wondering why there are separate methods for populating navigation properties. If I work on an entire set, i can call Include on either a property or a collection. However, if I work on a s...
Ford asked 6/8, 2013 at 5:14

1

I've configured my DbContext (EF Core 5.0) with the following code: protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity<User>() .HasMany(p => p.Roles...

4

Solved

While working in a project I saw a strange behaviour I cannot understand with the loading of navigation properties. Here is a small example that reproduces this "problem". I want to load a Year...

1

I am using Entity framework v 6.1.1 in my application. My database has 2 tables User, Location. User table ----------- UserID HomeCityId(FK -> LocationId) CurrentCityId(FK -> LocationId) Lo...

2

Solved

The usual approach for modeling 1-n relations with EntityFramwork (Code First) is to use virtual collection properties like: class Project { public virtual ICollection<Remark> Remarks { get...
Chrisom asked 5/2, 2013 at 14:54

6

Solved

I had seen some books(e.g programming entity framework code first Julia Lerman) define their domain classes (POCO) with no initialization of the navigation properties like: public class User { pu...

5

Solved

As I remember in EF navigation property should be virtual: public class Blog { public int BlogId { get; set; } public string Name { get; set; } public string Url { get; set; } public stri...

1

Solved

I am using Entity Framework (with a code-first approach) and the database is created successfully with the expected foreign keys and unique key constraints. I have those two model classes: publi...

3

I've got POCO domain entities that are persisted using Entity Framework 5. They are obtained from the DbContext using a repository pattern and are exposed to a RESTful MVC WebApi application throug...

1

Solved

There is an interesting feature exists in entity framework core: Entity Framework Core will automatically fix-up navigation properties to any other entities that were previously loaded into th...

2

Solved

Is it somehow possible to define navigation properties in EFCore with private or protected access level to make this kind of code work: class Model { public int Id { get; set; } virtual protecte...

1

Solved

Using EF Core 1.1.0 I have a model that has collections that themselves have collections. public class A { public string Ay {get;set;} public List<B> Bees {get;set;} } public class B {...
Encarnacion asked 8/1, 2017 at 3:12

3

Solved

Let's suppose that we have this situation: Tables in database: Country (id, country_name), Person (id, login), CountryManager (id_country, id_person), CountryStakeholder (id_country, id_person) ...

4

I'm working on an EF 5 Code-First solution and I am trying to update an existing entity with a modified one using the Repository pattern: public void UpdateValues(T originalEntity, T modifiedEnti...
Carmen asked 26/7, 2013 at 16:44

2

Solved

When I use the .Include syntax in EF6, reverse navigation properties are always loaded. Is there a way to turn that off? Here is a sample query. private static IQueryable<Account> GetAccount...
Salesgirl asked 28/8, 2015 at 14:46

1

I have the following customer class: public class Customer { public long Id { get; set; } public virtual ICollection<Order> Orders { get; set; } } My database has Customers and Orders ...

4

I'm trying to put together a simple toy project using Entity Framework, WebAPI, OData, and an Angular client. Everything is working fine, except the navigation property that I have put on one of my...

1

Solved

How do I configure Entity Framework using fluent configuration to behave the same way that I would do this with attributes: public class Product { public int? ParentId { get; set; } [ForeignKey(...

2

Solved

Using EF 5, Code First. I'd like to model my entities such that the navigation properties only exist on one side of the relationship. So if I have a table Widget, and a table WidgetType: public ...

1

Solved

I have following POCO class being used in EF 6.x. My question: Why is the navigation property of 'Posts' under 'Blog' entity declared as virtual? public class Blog { public int BlogId { get; s...
Eusporangiate asked 7/9, 2014 at 22:52

3

Solved

sorry for my english, I'll try to be short and concise. I have to tables "ALUMNOS" and "MATERIAS". In SQL exist another table "ALUMNOS BY MATERIAS". I know this is not necessary in EF because exis...
Pressley asked 10/6, 2014 at 12:24

1

Solved

Let's make a case to explain my problem. MyTable1 +id +myTable2Id MyTable2 +id MyView1 +id +myTable2Id MyView1 exists in the case, from data from the MyTable1. Now i want to creat...

2

Solved

I generated an Entity Framework Model (4.0) from my database. I did not design the database and do not have any control over the schema, but there are a few tables that do not have foreign key cons...

1

Sometimes entity framework generates awful navigation property names. Using the database first approach, what is the best way to fix that? I am able to edit the t4 templates to my liking, but how ...
Goodfellowship asked 22/7, 2013 at 18:0

© 2022 - 2024 — McMap. All rights reserved.