I'm a beginner to Entity Framework .
I notice that When I use EF6 with Visual studio 2013
:
I have .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 code like this:
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 .tt
file with .cs
file for each entity like Customer.cs
With code like this :
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 's totally different when i use EF4.1 with visual studio 2010
,
there's only one code behind file .Designer.cs
for the model !!
- Could some one help me to understand what are all these files for
.Context.tt
,.Context.cs
,.tt
,.cs
?and what 's different in files hierarchy between the two cases(EF6,EF4.1)
? - I can't find
OnPropertyChanging(Value) & OnPropertyChanged()
inEF6
to validate my entities !!Why these methods no longer exist and how to validate my properties if they do not exist?