I have a class named Users.cs which was created Code first from database:
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.Spatial;
using BookingsModel;
namespace BookingsModel
{
public partial class Users
{
[Key]
public int UserID { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string EmailID { get; set; }
public Nullable<System.DateTime> DateOfBirth { get; set; }
public string Password { get; set; }
public bool IsEmailVerified { get; set; }
public System.Guid ActivationCode { get; set; }
public static object ReferenceEquals(bool v)
{
throw new NotImplementedException();
}
}
}
Within my project > Models I have created a folder named Extended and created a Users.cs file in there:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using BookingsModel;
namespace Bookings.Models
{
public partial class Users
{
}
}
I have taken extended from the namespace and added partial into the name thinking it would make reference to the db Users class but it has not.
How can I make reference to that class?
You need to put the extended partial in the same namespace as the original class so change it to BookingsModel
.
Right now you have them in different namespaces so they are treated like 2 different types because the name of the class includes the namespace.
Note:
If you want the autogenerated class to have a different namespace, DO NOT simply change it because it will be overwritten the next time it is generated. Instead right click on the .tt
file and choose Properties
and change the namespace there.