I am starting to work with Entity Framework.
I notice that when I use EF6 with Visual studio 2013 :
I have a .Designer.cs empty file with this comment:
// T4 code generation is enabled for model 'C:\Users\Luka\Desktop\Test\EF-db2008\AdventureWorks\AdventureWorksLib\AdventureWorksLib\AWLTModel.edmx'. // To enable legacy code generation, change the value of the 'Code Generation Strategy' designer // property to 'Legacy ObjectContext'. This property is available in the Properties Window when the model // is open in the designer. // If no context and entity classes have been generated, it may be because you created an empty model but // have not yet chosen which version of Entity Framework to use. To generate a context class and entity // classes for your model, open the model in the designer, right-click on the designer surface, and // select 'Update Model from Database...', 'Generate Database from Model...', or 'Add Code Generation // Item...'.
.Context.tt and its .Context.cs with this code:
public partial class AWLTEntities : DbContext { public AWLTEntities() : base("name=AWLTEntities") { } protected override void OnModelCreating(DbModelBuilder modelBuilder) { throw new UnintentionalCodeFirstException(); } public virtual DbSet<Address> Addresses { get; set; } public virtual DbSet<Customer> Customers { get; set; } }
And then a .tt file with a .cs file for each object, for example Customer.cs
With this code:
public partial class Customer { public Customer() { this.NameStyle = false; this.CustomerAddresses = new HashSet<CustomerAddress>(); this.Orders = new HashSet<Order>(); } public int CustomerID { get; set; } }
This is completely different if I use EF4.1 with visual studio 2010 , there is only one code per .Designer.cs file for the model !!
- Can someone help me understand what all these files are for
.Context.tt , .Context.cs , .tt , .cs ? and which are different in the file hierarchy between the two cases (EF6,EF4.1) ? - I can not find
OnPropertyChanging(Value) & OnPropertyChanged() in EF6 to check my entities !! Why do these methods no longer exist and how to check my objects? properties if they do not exist?
source share