Quantcast
Channel: Entity Framework
Viewing all articles
Browse latest Browse all 10318

Commented Issue: EF5.0 bug [882]

$
0
0
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Configurations.Add(new CustomerMap());
//this is another namespace type
modelBuilder.Configurations.Add(new MvcApplication1.Models.A.CustomerMap());
base.OnModelCreating(modelBuilder);
}
///////---------------------------------Class1.cs---------------------------------------------
namespace MvcApplication1.Models
{
public class Customer
{
public int Id { get; set; }
public string Email { get; set; }
}
public class CustomerMap : EntityTypeConfiguration<Customer>
{
public CustomerMap()
{
this.ToTable("CustomerA");
this.HasKey(t => t.Id);
}
}
}

#warning this is another namespace,it has a class that the class name same to 'MvcApplication1.Models.Customer' -- Customer

namespace MvcApplication1.Models.A
{
public class Customer
{
public int Id { get; set; }
public string Email { get; set; }
}
public class CustomerMap : EntityTypeConfiguration<Customer>
{
public CustomerMap()
{
this.ToTable("CustomerB");
this.HasKey(t => t.Id);
}
}
}
//------------------------------------------------------------------------

run abover code it's throw the exception:

未映射类型“MvcApplication1.Models.A.Customer”。请检查是否未使用 Ignore 方法或 NotMappedAttribute 数据注释显式排除该类型。验证该类型是否定义为类,不是基元、嵌套或泛型类型,并且不从 EntityObject 继承。


what's why ???
Comments: i guess that it use Type.Name instead of using Type.FullName in EF source at the reflector time

Viewing all articles
Browse latest Browse all 10318

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>