I am trying to build a database with multiple tables in MVC.
I built a model.cs with the table attributes and let Entity Framework do its thing.
Now I want to create a new table in the same database and link them.
I have tried “creating new table” in the database where my previous table exists. This hands out a type-mismatch exception, invalid key exception, etc…
I also tried adding a new class within the model and tying it to the context…that doesn’t help either…
code looks SOMETHING like this….
namespace bleh.bleh
{
public partial class T1
{
//.....attributes primary key
}
public class T2
{
//...attributes foreign key to T1
}
public class TEntity : DbContext
{
public DbSet<T1> Tab1....
public DbSet<T2> Tab2....
}
}
Please advise…
Here’s the solution I found: add the following line in the StartApplication method of the global.asax file: