ef-fluent-api

What is Entity Framework fluent api?

陌路散爱 提交于 2019-12-02 14:09:40
I keep hearing about the Entity Framework fluent-api but I am struggling to find a good reference on this. What is it? We use the entity framework and the modeling tool provided. Is that all that is? Or is it something different? Similarly, if it's not too broad a question, what is POCO? I know it stands for Plain Old CLR Objects, but what does that mean to me as somebody who uses EF already with the designer model tool? If that question is too vague then please ignore it. I'm just learning here and any information you are willing to provide is helpful. Jason Evans Entity Framework 4.1

aspnet core entity framework 7 self referencing “job” 1 to many table

吃可爱长大的小学妹 提交于 2019-12-02 04:54:40
I have a "Job" table that contains jobs. The fact is Jobs are not always done in one go.. you can have a job that has many visits. I intended to represent that as another job but linked back to the original job via self referencing linkId. I am having trouble representing this using the fluent API. Its a one to many relationship.. one job might have many visits and thus a number of linkId's point back to the orginal job. The link Id would back to the orginal job Id. Its also optional since most jobs might be completed in one go.. I have looked for this but its difficult to turn the other

Column Extent1.Id does not exist in Mono with Entity Framework 6 and PostgreSQL

£可爱£侵袭症+ 提交于 2019-12-02 04:52:00
I am trying to map to a PostgreSQL database with Entity Framework using the packages Npsql and Npsql.EntityFramework . I have a database with the following table: CREATE TABLE IF NOT EXISTS Crops ( Id INT PRIMARY KEY NOT NULL, Name TEXT NOT NULL, SowingMonths INT ); The Crop model looks as follows: public class Crop { public int Id { get; set; } public string Name { get; set; } public Month SowingMonths { get; set;} //Month is an enum } In the database context I map the schema to public since all tables are in the schema public by default in PostgreSQL. protected override void OnModelCreating

How to handle many to many same table (User) in ASP.Net MVC 5 - Fluent API

对着背影说爱祢 提交于 2019-12-02 03:25:47
I am learning ASP.Net MVC 5 and I am stuck with one basic DB Design. So, I have one User which can refer many person in job Also, many person can apply to get themselves Referred. I have created two roles and all of that is taken care. Now, I have on class called Referral which will keep track of every instance of Referral that needs to be done. Referral Model: Public class Referral { [Key] public int ReferralId { get; set; } public Company Company { get; set; } public int CompanyId { get; set; } public ApplicationUser User { get; set; } public string CandidateId { get; set; } // Application

Optional One-to-many Relationship in Entity Framework

巧了我就是萌 提交于 2019-12-01 20:18:04
问题 I'm having issues getting an optional one-to-many relationship to work. My model is: public class Person { public int Identifier { get; set; } ... public virtual Department Department { get; set; } } public class Department { public int Identifier { get; set; } ... public virtual IList<Person> Members { get; set; } } I want to assign zero or one Department to a Person . When assigned, the Person should show up in the Members -List of the Department . I'm configuring the Person using the

Entity Framework - Fluent APi - Create table with 2 FK

萝らか妹 提交于 2019-12-01 13:05:30
I have this product class which has a list of products associated. eg: Product = StarWar AssociatedProducts = Episode V: The Empire Strikes Back, Episode VI: Return of the Jedi, Episode VII: The Force Awakens But EF generates the database with some extra columns. This is my Product Class: public class Product { public int Id { get; set; } public string Name { get; set; } public string ShortDescription { get; set; } public string FullDescription { get; set; } public decimal UnitPrice { get; set; } ...... public virtual ICollection<AssociatedProducts> AssociatedProducts { get; set; } ...... }

Fluent Api Entity Framework core

蹲街弑〆低调 提交于 2019-12-01 03:48:28
问题 A user can have 1 or 0 account public class User { public int UserId { get; set; } public string Name { get; set; } public string Email { get; set; } public Account Account { get; set; } } public class Account { public int AccountId { get; set; } public DateTime CreatedDateTime { get; set; } public User User { get; set; } } This is the fluent api code using Entity Framework 6 public class ClassDbContext: DbContext { protected override void OnModelCreating(DbModelBuilder modelBuilder) {

Entity framework Fluent API does not consider base class properties

前提是你 提交于 2019-12-01 01:21:30
EF 6.1 : We just started a project that has a lot pf inheritance. The selected inheritance db mapping type is the table per hierarchy. The problem is that when trying to generate the migration using the add-migration, the following error is thrown : The foreign key component 'VersionId' is not a declared property on type 'SER'. Verify that it has not been explicitly excluded from the model and that it is a valid primitive property. Here are the classes & the configuration classes used : public class Version : BaseObject { public virtual ICollection<SER> ListOfSER { get; set; } } public

Entity framework Fluent API does not consider base class properties

ぐ巨炮叔叔 提交于 2019-11-30 20:41:42
问题 EF 6.1 : We just started a project that has a lot pf inheritance. The selected inheritance db mapping type is the table per hierarchy. The problem is that when trying to generate the migration using the add-migration, the following error is thrown : The foreign key component 'VersionId' is not a declared property on type 'SER'. Verify that it has not been explicitly excluded from the model and that it is a valid primitive property. Here are the classes & the configuration classes used :

How to create spatial index using EF 6.1 fluent API

一曲冷凌霜 提交于 2019-11-30 19:55:58
Well, the question is clear enough. Is it possible to create spatial indexes using Entity Framework 6.1 fluent API? Short answer- No, it is not. I have seen this tangentially referenced throughout blogs and have found no concrete examples of implementation. It seems to be related to the fact that spatial indexes are filtered indexes, which are not supported in Entity Framework. As support for my answer I constructed a POC console app with the most recent version of Entity Framework (6.1). I took the following steps Created a model that had a property of the type DbGeography Enabled automatic