table-per-hierarchy

EF4.1 Exception creating Database with table-per-hierarchy inheritance

断了今生、忘了曾经 提交于 2019-12-04 14:09:38
I have created a very simple project to demonstrate table-per-hierarchy inhertiance. In my unit test which tries to generate the database, i get one of a number of errors depending on the config: without the Required() method Map<InActiveUser>(x => x.Requires("IsActive").HasValue(false)); Map<ActiveUser>(x => x.Requires("IsActive").HasValue(true)); delivers: System.Data.DataException : An exception occurred while initializing the database. See the InnerException for details. ----> System.Data.EntityCommandCompilationException : An error occurred while preparing the command definition. See the

Entity Framework 6 & TPH inheritance: Map properties with the same name to same column by default

£可爱£侵袭症+ 提交于 2019-12-03 12:44:37
As of EF6 it is possible to do something like this when configuring Entity mappings using Table Per Hierarchy inheritance: public class MyContext : DbContext { public DbSet<Device> Devices { get; set; } protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Entity<ABatteryPoweredDevice>().Property(c => c.BatteryLevel).HasColumnName("BatteryLevel"); modelBuilder.Entity<ADifferentBatteryPoweredDevice>().Property(c => c.BatteryLevel).HasColumnName("BatteryLevel"); } } BatteryLevel is not part of the Device base class- it is a property of the derived classes

Entity Framework 4 Table Per Hierarchy - How To Define Navigational Properties On Children?

六月ゝ 毕业季﹏ 提交于 2019-12-03 12:25:25
问题 I currently have a Entity Framework 4.0 model in place with Table Per Type (TPT), but there are a few performance issues (lots of LOJ's/CASE statements), as well as an issue mapping between two particular domain areas (many-to-many). I've decided to try out TPH. I have an entity called " Location " which is abstract , and the base for all other entities. I then have " Country ", " City ", " State ", " Street ", etc which all derive from Location. " LocationType " is the dicriminator . That

Entity Framework 4 Table Per Hierarchy - How To Define Navigational Properties On Children?

我是研究僧i 提交于 2019-12-03 02:48:58
I currently have a Entity Framework 4.0 model in place with Table Per Type (TPT), but there are a few performance issues (lots of LOJ's/CASE statements), as well as an issue mapping between two particular domain areas (many-to-many). I've decided to try out TPH. I have an entity called " Location " which is abstract , and the base for all other entities. I then have " Country ", " City ", " State ", " Street ", etc which all derive from Location. " LocationType " is the dicriminator . That part is working fine, but i'm having issues trying to define navigational properties for the derived

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 :