I have added a new table to the localDB called ChatLog where I store chat messages and I have created 3 stored procedures for the table.
I've been looking online on how to configure that table for Entity Framework but I can't find a solution that works for me, I've even tried the override work arounds but usually there's an error revolving around DbContext that's not pulled from services.
I'm new at this and don't really know what I should do, and as I said, tutorials arent really helping since I lack the knowledge.
could some one give me a hand here? the table looks like this:
Column | type
----------------------------
SenderId | nvarchar(256)
RecipientId | nvarchar(256)
Message | ntext
Time | date
I have tried writing this, but it doesn't work:
[Table("ChatLog")]
public class ChatMessage
{
[Required]
[Column("SenderId")]
public string SenderId { get; set; }
[Required]
[Column("RecipientId")]
public string RecipientId { get; set; }
[Required]
[Column("Message")]
public string Message { get; set; }
[Required]
[Column("Time")]
public DateTime Time { get; set; }
}
class ChatLogContext : DbContext
{
public DbSet<ChatMessage> ChatMessages { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<ChatMessage>()
.ToTable("ChatLog");
}
}
Data First ApproachorModel First Approach?