1
Hello, I am creating a solution in Visual Studio in which I would like to separate all layers of the application in projects to have a better defined structuring. My solution until then is like this:
Solution
| - Database (Database Project)
| - Tables
| - ...
| - Model (Class Library)
| - ...
| - Kernel (Class Library)
| - Interfaces
| - IIndexable
| - IStatusControlable
| - ITraceableCreation
| - ITraceableUpdate
The idea of this structure is that I can define interfaces of implementations that I can force the implementation of them in models or any other structure that is based on business rules (Kernel). From this I have the implementation of these interfaces:
interface IIndexable
{
int Id { get; set; }
}
interface IStatusControlable
{
string Status { get; set; }
}
interface ITraceableCreation
{
DateTime CriadoEm { get; set; }
}
interface ITraceableUpdate
{
DateTime AtualizadoEm { get; set; }
}
The problem is that, when creating the database project, I must also force the implementation of the fields for the tables and the like, for example if I had a class Usuario
, the implementation of it would have this structure
class Usuario: IIndexable, IStatusControlable, ITraceableCreation, ITraceableUpdate
{
public int Id { get; set; }
public string Status { get; set; }
public DateTime CriadoEm { get; set; }
public DateTime AtualizadoEm { get; set; }
public string Login { get; set; }
public string Senha { get; set; }
public string Email { get; set; }
}
And its implementation within the database would reflect this:
create table Usuario (
Id int not null identity primary key,
Status nchar(1) not null default 'a',
CriadoEm datetime not null default getdate(),
AtualizadoEm datetime not null default getdate(),
Login nvarchar(50) not null unique,
Senha nvarchar(100) not null,
Email nvarchar(100) not null unique
);
The problem is that, if the project is in development progress and some more variation arises, for example, it has been defined that the interface IStatusControlable
will now be controlled using an internal Enum like this:
enum StatusControlableEnum {
Ativo, Inativo, Removido, Protegido, Estatico
}
interface IStatusControlable
{
StatusControlableEnum Status { get; set; }
}
What makes the property guy Status
become StatusControlableEnum
and all structures that use this interface have to change.
The problem is that this change is not reflected directly to the database project, making all references of the construction of the tables that represent elements that contain that interface have to be managed manually.
Is there any way to use interfaces or at least indicate the incorrect implementation of some interface for a table defined in a Database Project
in Visual Studio?