Hello, I'm creating a solution in Visual Studio where I would like to separate all layers of the application into projects to have a more well-defined structuring. My solution so far looks 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 implementation interfaces that I can force to implement them in models or in any other structure that is based on the kernel rules. 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 the same 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 your implementation within the database would reflect on 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 development and there is some variation, for example, it has been defined that the IStatusControlable
interface will now be controlled using an internal enum like this:
enum StatusControlableEnum {
Ativo, Inativo, Removido, Protegido, Estatico
}
interface IStatusControlable
{
StatusControlableEnum Status { get; set; }
}
What causes the Status
property type to 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 construction references of tables representing persistencies that contain that interface have to be handled 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?