I have next entity configuration:
public class OfficesContext : DbContext
{
public DbSet<Office> Offices { get; set; }
public DbSet<Expense> Expenses { get; set; }
public DbSet<ExpenseLog> ExpenseLogs { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<Office>()
.Property(o => o.OfficeId)
.HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
modelBuilder.Entity<Expense>()
.Property(o => o.ExpenseId)
.HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
modelBuilder.Entity<Office>()
.HasMany(o => o.Expenses)
.WithMany()
.Map(mc =>
{
mc.ToTable("ExpenseLogs");
mc.MapLeftKey("ExpenseId");
mc.MapRightKey("OfficeId");
});
}
}
public class Office
{
public Office()
{
ExpenseLogs = new HashSet<ExpenseLog>();
Expenses = new HashSet<Expense>();
}
public int OfficeId { get; set; }
public string Name { get; set; }
public ICollection<ExpenseLog> ExpenseLogs { get; private set; }
public ICollection<Expense> Expenses { get; private set; }
}
public class Expense
{
public Expense()
{
ExpenseLogs = new HashSet<ExpenseLog>();
Offices = new HashSet<Office>();
}
public int ExpenseId { get; set; }
public string Name { get; set; }
public ICollection<ExpenseLog> ExpenseLogs { get; private set; }
public ICollection<Office> Offices { get; private set; }
}
public class ExpenseLog
{
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int ExpenseLogId { get; set; }
public int OfficeId { get; set; }
public Office Office { get; set; }
public int ExpenseId { get; set; }
public Expense Expense { get; set; }
public DateTime InputDate { get; set; }
public decimal Amoun { get; set; }
public string Description { get; set; }
}
But it creates two tables for expences logs ExpenseLogs and ExpenseLogs1. ExpenseLogs has only foreign keys ExpenseId and OfficeId. ExpenseLogs1 has same fields as in class ExpenseLog. I also tried to use next mappings but it doesnt helped:
modelBuilder.Entity<ExpenseLog>().HasRequired(e => e.Office);
modelBuilder.Entity<ExpenseLog>().HasRequired(e => e.Expense);
You have some redundant configuration Try these changes:
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<Office>()
.Property(o => o.OfficeId)
.HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
modelBuilder.Entity<Expense>()
.Property(o => o.ExpenseId)
.HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
// ** this is redundant - ef will figure it from the bridge class **
// modelBuilder.Entity<Office>()
// .HasMany(o => o.Expenses)
// .WithMany()
// .Map(mc =>
// {
// mc.ToTable("ExpenseLogs");
// mc.MapLeftKey("ExpenseId");
// mc.MapRightKey("OfficeId");
// });
}
public class Office
{
public Office()
{
ExpenseLogs = new HashSet<ExpenseLog>();
Expenses = new HashSet<Expense>();
}
public int OfficeId { get; set; }
public string Name { get; set; }
public ICollection<ExpenseLog> ExpenseLogs { get; private set; }
// access offices thru ExpenseLogs
// public ICollection<Expense> Expenses { get; private set; }
}
public class Expense
{
public Expense()
{
ExpenseLogs = new HashSet<ExpenseLog>();
Offices = new HashSet<Office>();
}
public int ExpenseId { get; set; }
public string Name { get; set; }
public ICollection<ExpenseLog> ExpenseLogs { get; private set; }
// access offices thru ExpenseLogs
// public ICollection<Office> Offices { get; private set; }
}
See Create code first, many to many, with additional fields in association table
Related
I have 4 classes in dbcontext,it's EventRemind.cs Event.cs House.cs Customer.cs,the code like this:
public class EventRemind
{
[Key]
public Guid Id { get; set; }
public Guid CustomerEventId { get; set; }
public DateTime RemindTime { get; set; }
public bool HasRead { get; set; }
public DateTime CreatedTime { get; set; }
[ForeignKey("CustomerEventId")]
public virtual Event CustomerEvent { get; set; }
}
public class Event
{
[Key]
public Guid Id { get; set; }
public string Title { get; set; }
public int UserId { get; set; }
public int HouseId { get; set; }
[MaxLength(800)]
public string Content { get; set; }
public DateTime CreatedTime { get; set; }
[ForeignKey("HouseId")]
public virtual House House { get; set; }
[ForeignKey("UserId")]
public virtual Customer Customer { get; set; }
public virtual ICollection<EventRemind> EventReminds { get; set; }
}
public class House
{
public int Id { get; set; }
public string Name { get; set; }
public virtual ICollection<Event> HouseEvents { get; set; }
}
public class Customer
{
public int Id { get; set; }
public string Name { get; set; }
public virtual ICollection<Event> CustomerEvents { get; set; }
}
and my dbcontext is this:
public class DataContext:DbContext
{
public DataContext(DbContextOptions options) : base(options)
{
}
public DbSet<EventRemind> EventReminds { get; set; }
public DbSet<Event> Events { get; set; }
public DbSet<House> Houses { get; set; }
public DbSet<Customer> Customers { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
}
}
that means an eventRemind include an event,an event include a house and a customer,now what puzzles me is that what should I do to get the House and Customer at the same time from EventReminds,what I want is this:
var query = _dataContext.EventReminds.Include(c => c.CustomerEvent)
.ThenInclude(c => c.Customer).ThenInclude(c => c.House //this get a compile error);
why dis this happen? Can somebody help me? Thanks in advance.
I think your last operator should be just Include. Try this:
var query = _dataContext.EventReminds
.Include(c => c.CustomerEvent)
.ThenInclude(c => c.Customer)
.Include(c => c.House);
You have to write code following way.
Way1
var query =
_dataContext.EventReminds.Include(c => c.CustomerEvent).ThenInclude(c => c.Customer)
.Include(c=> c.CustomerEvent).ThenInclude(c => c.House);
Way2 (If property is not collection then it is usefull)
var query =
_dataContext.EventReminds.Include(c=> c.CustomerEvent).
.Include(c=> c.CustomerEvent.Customer)
.Include(c=> c.CustomerEvent.House);
I dont know alot of English Lang But I will try...
so i have this error
Introducing FOREIGN KEY constraint 'FK_Conversation_User_Users_UserID' on table 'Conversation_User' may cause
cycles or multiple cascade paths.
Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints.
and my code is:
AppDB:
public class AppDB : DbContext
{
public AppDB() : base() { }
public AppDB(DbContextOptions<AppDB> options) : base(options) { }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlServer(#"Server=(LocalDB)\MSSQLLocalDB;Database=TetraMessangerDB;Trusted_Connection=True;");
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Conversation_User>().HasKey(cu => new { cu.ConversationID, cu.UserID });
modelBuilder.Entity<Message_Media>().HasKey(mm => new { mm.MediaID, mm.MessageID });
modelBuilder.Entity<Participant>().HasKey(p => new { p.UserID, p.GroupID });
}
public DbSet<User> Users { get; set; }
public DbSet<Conversation_User> Conversation_User { get; set; }
public DbSet<Conversation> Conversation { get; set; }
}
User:
public class User
{
public User()
{
Participants = new List<Participant>();
SenMessages = new List<Message>();
ResMessages = new List<Message>();
}
public int UserID { get; set; }
public string Name { get; set; }
public string Password { get; set; }
public string Bio { get; set; }
public string EMail { get; set; }
public string UserName { get; set; }
public bool Activate { get; set; }
public int MediaID { get; set; }
public virtual Media Media { get; set; }
public virtual UserStatus UserStatus { get; set; }
public virtual List<Participant> Participants { get; set; }
[InverseProperty("SenderUser")]
public virtual List<Message> SenMessages { get; set; }
[InverseProperty("ReciverUser")]
public virtual List<Message> ResMessages { get; set; }
public virtual List<Conversation_User> Conversation_User { get; set; }
}
Conversation:
public class Conversation
{
public Conversation()
{
Conversation_User = new List<Conversation_User>();
}
public int ConversationID { get; set; }
public DateTime StartDate { get; set; }
public int MediaID { get; set; }
public virtual Media Media { get; set; }
public virtual List<Conversation_User> Conversation_User { get; set; }
}
Conversation_User:
public class Conversation_User
{
public int ConversationID { get; set; }
public virtual Conversation Conversation { get; set; }
public int UserID { get; set; }
public virtual User User { get; set; }
}
so I see alot of same quastion but i dont understand ...
i dont have multiple path so why i get this error.
can some body explain this.
Note: I have alot of entitys with the same problem in Many-To-Many Relationship but if i can solve this, I will understand how to solve thim.
and thanks for helping me.
Edit: I tried this but still getting the same
modelBuilder.Entity<Conversation_User>()
.HasOne(pt => pt.User)
.WithMany(p => p.Conversation_User)
.HasForeignKey(pt => pt.UserID)
.IsRequired()
.OnDelete(DeleteBehavior.NoAction);
modelBuilder.Entity<Conversation_User>()
.HasOne(pt => pt.Conversation)
.WithMany(p => p.Conversation_User)
.HasForeignKey(pt => pt.ConversationID)
.IsRequired()
.OnDelete(DeleteBehavior.NoAction);
I'm trying to straighten out the EF-Model for a junctiontable OwnerCows.dbo.
There's a class Cow with an Id, a class Owner with an Id and i want to reference them both in a OwnerCows-table that has only an OwnerCowId, a CowId(FK) and a OwnerId(FK).
The error I'm getting is:
Cannot create a relationship between 'Owner.OwnerCows' and 'OwnerCow.Owner', because there already is a relationship between 'Owner.CowOwners' and 'OwnerCow.Owner'. Navigation properties can only participate in a single relationship.
Does it mean I have a circular reference? How can I solve this?
the Owner.cs:
public class Owner : EntityBase<Guid>
{
public string Name { get; set; }
[NotMapped]
public ICollection<Cow> Cows { get; set; }
= new List<Cow>();
public virtual List<OwnerCow> CowOwners { get; set; }
public Cow Cow { get; set; }
}
the Cow.cs:
public class Cow : EntityBase<Guid>
{
[MaxLength(50)]
public string Name { get; set; }
public string Breed { get; set; }
public string Color { get; set; }
public ICollection<Entities.Weight> Weights { get; set; }
= new List<Weight>();
public ICollection<Vaccination> Vaccinations { get; set; }
= new List<Vaccination>();
[NotMapped]
public ICollection<Owner> CowOwners { get; set; }
= new List<Owner>();
public List<OwnerCow> OwnerCows { get; set; }
}
the OwnerCows.cs:
public class OwnerCow
{
public Guid OwnerCowId { get; set; }
public Cow Cow { get; set; }
public Guid CowId { get; set; }
public Owner Owner { get; set; }
public Guid OwnerId { get; set; }
}
the Context-class:
public class DogFaceContext : DbContext
{
public DogFaceContext()
{
}
public DogFaceContext(DbContextOptions<DogFaceContext> options)
: base(options)
{
Database.Migrate();
}
//Entity Tables
public virtual DbSet<Owner> Owners { get; set; }
public virtual DbSet<Cow> Cows { get; set; }
public virtual DbSet<Vaccination> Vaccination { get; set; }
public virtual DbSet<Weight> Weight { get; set; }
//Junction Tables
public virtual DbSet<OwnerCow> OwnerCows { get; set; }
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
builder.Entity<Cow>().HasMany(x => x.CowOwners).WithOne(x => x.Cow);
builder.Entity<Owner>().HasMany(u => u.CowOwners).WithOne(X => X.Owner);
builder.Entity("DogFace.API.Entities.OwnerCow", b =>
{
b.HasOne("DogFace.API.Entities.Cow", "Cow")
.WithMany("OwnerCows")
.HasForeignKey("CowId")
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("DogFace.API.Entities.Owner", "Owner")
.WithMany("OwnerCows")
.HasForeignKey("OwnerId")
.OnDelete(DeleteBehavior.Restrict);
});
}
}
Can I get it to work with this design? Is it possible with EFCore? Any other suggestions? Thanks!
You model is very complex and has some unnecessary relationships like Owner.Cows since you decide to configure many-to-many relationship.You could just get Owner's cows using
var owner = new Owner();
List<Cow> cows = owner.OwnerCows.Where(oc => oc.OwnerId == owner.Id)
.Select(oc => oc.Cow)
.ToList();
1.To have OwnerCowId, a CowId(FK) and a OwnerId(FK) in OwnerCows, refer to my below configuration:
public class Owner : EntityBase<Guid>
{
public string Name { get; set; }
public virtual List<OwnerCow> OwnerCows { get; set; }
}
public class Cow : EntityBase<Guid>
{
[MaxLength(50)]
public string Name { get; set; }
public string Breed { get; set; }
public string Color { get; set; }
public ICollection<Entities.Weight> Weights { get; set; } = new List<Weight>();
public ICollection<Vaccination> Vaccinations { get; set; }= new List<Vaccination>();
public List<OwnerCow> OwnerCows { get; set; }
}
public class OwnerCow
{
[Key]
public Guid OwnerCowId { get; set; }
public Cow Cow { get; set; }
public Guid CowId { get; set; }
public Owner Owner { get; set; }
public Guid OwnerId { get; set; }
}
DbContext:
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
builder.Entity<OwnerCow>()
.HasOne(oc => oc.Cow)
.WithMany(c => c.OwnerCows)
.HasForeignKey(oc => oc.CowId);
builder.Entity<OwnerCow>()
.HasOne(oc => oc.Owner)
.WithMany(o => o.OwnerCows)
.HasForeignKey(oc => oc.OwnerId);
}
}
In this case, your OwnerCowId id the primary key for your OwnerCows table which is not reasonable and it may have the same record of CowId,OwnerId for OwnerCows.
2.Usually,the primary key for the join table is a composite key comprising both of the foreign key values,I suggest that you could use composite key for your OwnerCow:
public class OwnerCow
{
public Cow Cow { get; set; }
public Guid CowId { get; set; }
public Owner Owner { get; set; }
public Guid OwnerId { get; set; }
}
DbContext:
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
builder.Entity<OwnerCow>()
.HasKey(oc => new { oc.OwnerId, oc.CowId });
builder.Entity<OwnerCow>()
.HasOne(oc => oc.Cow)
.WithMany(c => c.OwnerCows)
.HasForeignKey(oc => oc.CowId);
builder.Entity<OwnerCow>()
.HasOne(oc => oc.Owner)
.WithMany(o => o.OwnerCows)
.HasForeignKey(oc => oc.OwnerId);
}
}
Refer to https://www.learnentityframeworkcore.com/configuration/many-to-many-relationship-configuration
Fix context builder:
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
builder.Entity<Cow>().HasMany(x => x.CowOwners).WithOne(x => x.Cow);
builder.Entity<Owner>().HasMany(u => u.Cows).WithOne(X => X.Owner); // Cows instead of CowOwners
builder.Entity("DogFace.API.Entities.OwnerCow", b =>
{
b.HasOne("DogFace.API.Entities.Cow", "Cow")
.WithMany("OwnerCows")
.HasForeignKey("CowId")
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("DogFace.API.Entities.Owner", "Owner")
.WithMany("CowOwners") // CowOwners instead of OwnerCows
.HasForeignKey("OwnerId")
.OnDelete(DeleteBehavior.Restrict);
});
}
... or fix property names in classes:
public class Owner : EntityBase<Guid>
{
public string Name { get; set; }
[NotMapped]
public ICollection<Cow> CowOwners { get; set; } // CowOwners instead of Cows ?
= new List<Cow>();
public virtual List<OwnerCow> OwnerCow { get; set; } // OwnerCow instead of CowOwners ?
public Cow Cow { get; set; }
}
but don't forget to change dbcontext builder with fixed property names.
I am building an application using ASP.NET Core MVC. I am trying to insert a new record with a many-to-many relationship. I have 3 tables Repairs, Parts and RepairParts.
How can I insert the RepairId and PartId into the RepairParts table? Does EF Core provide something for this? I searched the documentation but it doesn't mention anything about how to do this.
Does Entity Framework do this automatically? (insert to the pivot table) Or do I need to do it manually? An example would help.
Repair class:
public class Repair
{
[Key]
public int RepairId { get; set; }
public int VehicleId { get; set; }
public string Notes { get; set; }
public string Mileage { get; set; }
public DateTime RepairDate { get; set; }
public string uuid { get; set; }
[ForeignKey("VehicleId")]
public Vehicle Vehicle { get; set; }
public virtual ICollection<RepairParts> RepairParts { get; set; }
}
Part class:
public class Part
{
public int PartId { get; set; }
public int Code { get; set; }
public string PartCode { get; set; }
public string Type { get; set; }
public string Name { get; set; }
public string Descr { get; set; }
public string Manufacturer { get; set; }
public string uuid { get; set; }
public virtual ICollection<RepairParts> RepairParts { get; set; }
}
RepairPart class:
public class RepairParts
{
public int RepairId { get; set; }
public Repair Repair { get; set; }
public int PartId { get; set; }
public Part Part { get; set; }
public decimal price { get; set; }
}
DbContext class:
public class ApplicationDbContext : IdentityDbContext
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
: base(options)
{
}
public DbSet<Customer> Customers { get; set; }
public DbSet<TaxOffice> TaxOffices { get; set; }
public DbSet<Vehicle> Vehicles { get; set; }
public DbSet<Part> Parts { get; set; }
public DbSet<Repair> Repairs { get; set; }
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
builder.Entity<Customer>()
.HasMany(v => v.Vehicles)
.WithOne(b => b.Customer);
builder.Entity<Vehicle>()
.HasOne(c => c.Customer)
.WithMany(b => b.Vehicles);
builder.Entity<Vehicle>()
.HasMany(v => v.Repairs)
.WithOne(c => c.Vehicle);
builder.Entity<RepairParts>()
.HasKey(t => new { t.RepairId, t.PartId });
builder.Entity<RepairParts>()
.HasOne(r => r.Repair)
.WithMany(t => t.RepairParts)
.HasForeignKey(f => f.RepairId);
builder.Entity<RepairParts>()
.HasOne(r => r.Part)
.WithMany(p => p.RepairParts)
.HasForeignKey(f => f.PartId);
}
}
Here are two options for you:
Insert RepairParts by public virtual ICollection<RepairParts> RepairParts { get; set; }
var repaire = new Repair { uuid = "R3" };
var part = new Part { Code = 3 };
var reparePart = new RepairParts { Repair = repaire, Part = part };
repaire.RepairParts = new List<RepairParts>()
{
reparePart
};
_context.Add(repaire);
_context.SaveChanges();
Insert RepairParts explictly by _context.Add(reparePart1);
var repaire1 = new Repair { uuid = "RR1" };
var part1 = new Part { Code = 4 };
var reparePart1 = new RepairParts { Repair = repaire1, Part = part1 };
_context.Add(repaire1);
_context.Add(part1);
_context.Add(reparePart1);
_context.SaveChanges();
I'm unable to create correct mappings between DAO and DTO objects with many-to-many relations using AutoMapper.
Now I could map these many-to-many properties but the other ones were null.
What is the correct mapping? I see that models' attributes have the same name and type.
Also I'm trying to create the mapping between the parent models "ClaseFabricante" and "ClaseConstructor". Should I make it with the child ones which are many-to-many related "ReferenciaFabricante" and "ReferenciaConstructor" with ForMember()?
Entities:
[Table("ReferenciasFabricante", Schema = "public")]
public class ReferenciaFabricante
{
public string NombreFabricante { get; set; }
public string RefFabricanteIA { get; set; }
[InverseProperty("ReferenciaFabricante")]
public virtual ClaseFabricante Clase { get; set; }
[InverseProperty("ReferenciaFabricante")]
public virtual IList<ReferenciaFabricanteTieneReferenciaConstructor> MontaReferenciasConstructor { get; set; }
}
[Table("ReferenciasConstructor", Schema = "public")]
public class ReferenciaConstructor
{
public string Referencia { get; set; }
public string NombreConstructor { get; set; }
[InverseProperty("ReferenciaConstructor")]
public virtual ClaseConstructor Clase { get; set; }
[InverseProperty("ReferenciaConstructor")]
public virtual IList<ReferenciaFabricanteTieneReferenciaConstructor> MontadaPorReferenciasFabricante { get; set; }
}
[Table("ReferenciaFabricanteTieneReferenciaConstructor", Schema = "public")]
public class ReferenciaFabricanteTieneReferenciaConstructor {
[Key]
public int IdReferenciaFabricante { get; set; }
[ForeignKey("IdReferenciaFabricante")]
public ReferenciaFabricante ReferenciaFabricante { get; set; }
[Key]
public int IdReferenciaConstructor { get; set; }
[ForeignKey("IdReferenciaConstructor")]
public ReferenciaConstructor ReferenciaConstructor { get; set; }
}
[Table("ClasesFabricante", Schema = "public")]
public class ClaseFabricante
{
public int? IdReferenciaFabricante { get; set; }
[ForeignKey("IdReferenciaFabricante")]
public ReferenciaFabricante ReferenciaFabricante { get; set; }
}
[Table("ClasesConstructor", Schema = "public")]
public class ClaseConstructor
{
public int? IdReferenciaConstructor { get; set; }
[ForeignKey("IdReferenciaConstructor")]
public ReferenciaConstructor ReferenciaConstructor { get; set; }
}
ViewModels:
public class ReferenciaFabricante {
public string NombreFabricante { get; set; }
public string RefFabricanteIA { get; set; }
public virtual ClaseFabricante Clase { get; set; }
public virtual IList<ReferenciaConstructor> ReferenciasConstructor { get; set; }
}
public class ReferenciaConstructor {
public string Referencia { get; set; }
public string NombreConstructor { get; set; }
public virtual ClaseConstructor Clase { get; set; }
public virtual IList<ReferenciaFabricante> ReferenciasFabricante { get; set; }
}
public class ClaseFabricante {
public ReferenciaFabricante ReferenciaFabricante { get; set; }
}
public class ClaseConstructor {
public ReferenciaConstructor ReferenciaConstructor { get; set; }
}
Mapper initialization:
Mapper.Initialize((config) => {
config.CreateMap<ApplicationCore.Entities.ReferenciaFabricante, ApplicationCore.ViewModels.ReferenciaFabricante>()
;
config.CreateMap<ApplicationCore.Entities.ReferenciaConstructor, ApplicationCore.ViewModels.ReferenciaConstructor>()
;
config.CreateMap<ApplicationCore.Entities.ClaseFabricante, ApplicationCore.ViewModels.ClaseFabricante>()
.ForPath(dto => dto.ReferenciaFabricante.ReferenciasConstructor, opt => opt.MapFrom(x => x.ReferenciaFabricante.MontaReferenciasConstructor.Select(y => y.ReferenciaConstructor).ToList()))
.ForPath(dto => dto.ReferenciaFabricante.VersionesVehiculo, opt => opt.MapFrom(x => x.ReferenciaFabricante.MontaVersionesVehiculo.Select(y => y.VersionVehiculo).ToList()))
;
config.CreateMap<ApplicationCore.Entities.ClaseConstructor, ApplicationCore.ViewModels.ClaseConstructor>()
.ForPath(dto => dto.ReferenciaConstructor.ReferenciasFabricante, opt => opt.MapFrom(x => x.ReferenciaConstructor.MontadaPorReferenciasFabricante.Select(y => y.ReferenciaFabricante).ToList()))
;
});
Code:
foreach (ApplicationCore.Entities.ClaseFabricante cfDAO in vClasesFabricante) {
result.Add(AutoMapper.Mapper.Map<ApplicationCore.ViewModels.ClaseFabricante>(cfDAO));
}