Evening, Im sure that this is probably quite simple... but Im doing something wrong.
I am trying to create a solution with 3 (for now) projects:
I want to keep the models in a different project/assembly from the UI and the DAL because the models will be reusable between projects and we may want to swap out the DAL etc without having to mess about with the models etc...
Anyway, onto the problem.
I have created a few classes in my models project like :
public class Client
{
public int ClientID { get; set; }
public string Name { get; set; }
public string Address { get; set; }
public string PhoneNumber { get; set; }
public string Notes { get; set; }
public virtual Contact BillingContact { get; set; }
public virtual ICollection<Contact> Contacts { get; set; }
public virtual ICollection<Invoice> Invoices { get; set; }
}
I have then created a DBContext in the DAL
using System.Data.Entity;
using DBDS.Invoice.Models;
namespace DBDS.Invoice.DAL.EF
{
public class InvoiceDataContext : DbContext
{
public DbSet<Client> Clients;
}
}
I have enabled migrations on the DAL project, Added a migration and called update-database - the database has been created but with NO tables.
Anyway, Im sure Im being dense - any help will be appreciated.
Thanks
Clients
needs to be a property for Entity Framework to pick it up
public class InvoiceDataContext : DbContext
{
public DbSet<Client> Clients { get; set; }
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With