I am not sure if this is the correct way to go, if so, please advise otherwise.
This is an ASP.Net MVC 4 site using EF 5.x
Suppose you have your Entity Framework in a class library on it's own. Code Generation Item has now generated all of your Models (the xxx.tt section of your EF mode)
This project is then added/referenced in the development of a site.
You can now access the data via the EF.
Now - in the site project I want to create a partial class of one of my EF models, for example "Users", with an additional property that isn't in the DB.
In the past on a web forms project when the EF was part of the project and not a reference I would simply create the partial class and all would be good; my "Users" would now have a bunch of other stuff in it that wasn't database related but needed on the "User".
I can't seem to get this to work in this MVC project where the EF is in a separate project.
I have tried doing this for example:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MyTestEntity.Entity;
namespace MyTestMVCSite.Models
{
public partial class Email
{
public string OtherEmail {
get { return "me@myEmail.com"; }
}
}
}
I have also tried inheriting the EF models class, like this:
public partial class Email : MyTestEntity.Entity.Email
{
public string OtherEmail {
get { return "me@myEmail.com"; }
}
}
Nothing I seem to be doing gives me access to "OtherEmail"
What I actually want to be able to do is create a partial class for some of my models and then have this partial class implement an interface so i can inject an instance of this interface into another object rather than overloading.
Am i talking crazy nonsense?