Possible, it is, but you have to pay attention to a few things:
1. You need to have some domain mapped
When I refer to domain, I refer to your system having a class for each collection (or table) that your system uses, with each object representing a record of your collection (or table).
2. You will need to specify following a nomenclature, or use decoration attributes to make the Entity Framework understand your domain
The Entity Framework understands a domain object that is in the following form:
public class MeuObjeto
{
public int MeuObjetoId { get; set; }
}
He understands that MeuObjetoId
is a primary key of a collection (or table) called MeuObjeto
.
Or else:
public class MeuObjeto
{
public int Id { get; set; }
}
Or else:
public class MeuObjeto
{
[Key]
public int MinhaColunaDeIdPersonalizada { get; set; }
}
[Key]
indicates which property will be treated as the primary key.
3. You will need to tell us what the relationship between your entities is like
Basically there are 3:
1 to 1
public class MeuObjeto
{
[Key]
public int MeuObjetoId { get; set; }
public int OutroObjetoId { get; set; }
public virtual OutroObjeto OutroObjeto { get; set; }
}
1-N
public class MeuObjeto
{
[Key]
public int MeuObjetoId { get; set; }
public virtual ICollection<MeuObjetoDetalhe> MeuObjetoDetalhes { get; set; }
}
N para N
public class MeuObjeto
{
[Key]
public int MeuObjetoId { get; set; }
public virtual ICollection<AssociacaoObjeto> AssociacaoObjetos { get; set; }
}
public class OutroObjeto
{
[Key]
public int OutroObjetoId { get; set; }
public virtual ICollection<AssociacaoObjeto> AssociacaoObjetos { get; set; }
}
public class AssociacaoObjeto
{
[Key]
public int AssociacaoObjetoId { get; set; }
public int OutroObjetoId { get; set; }
public int MeuObjetoId { get; set; }
public virtual MeuObjeto MeuObjeto { get; set; }
public virtual OutroObjeto OutroObjeto { get; set; }
}
Goes by Fluent Nhibernate
– Tony