I am creating my models manually.
I have five tables in my database as follows :
1. Members
2. MemberTypeMasters
3. Payments
4. Relationships
5. StatusMasters
My Database looks like :
So far I have 6 files containing auto-implemented properties as below :
Models
|-- DBCS.cs
|-- Member.cs
|-- MemberTypeMaster.cs
|-- Payment.cs
|-- Relationship.cs
|-- StatusMaster.cs
Code in DBCS.cs
using System;
using System.Data.Entity;
namespace Munim_File_Sharing.Models
{
public class DBCS : DbContext
{
public DbSet<Member> Members { get; set; }
public DbSet<MemberTypeMaster> MemberTypeMasters { get; set; }
public DbSet<Payment> Payments { get; set; }
public DbSet<Relationship> RelationShips { get; set; }
public DbSet<StatusMaster> StatusMasters { get; set; }
}
}
Code in Member.cs
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace Munim_File_Sharing.Models
{
public class Member
{
[Key]
public int MemberID { get; set; }
public string Name { get; set; }
public string Password { get; set; }
public string MobileNo { get; set; }
public string FileName { get; set; }
public Nullable<DateTime> MemberSince { get; set; }
public int MemberTypeID { get; set; }
public virtual MemberTypeMaster MemberTypeMaster { get; set; }
public virtual ICollection<Payment> Payments { get; set; }
public virtual ICollection<Relationship> RelationshipSenders { get; set; }
public virtual ICollection<Relationship> RelationshipReceivers { get; set; }
}
}
Code in MemberTypeMaster.cs
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace Munim_File_Sharing.Models
{
public class MemberTypeMaster
{
[Key]
public int MemberTypeID { get; set; }
public string MemberType { get; set; }
public ICollection<Member> Members { get; set; }
}
}
Code in Payment.cs
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace Munim_File_Sharing.Models
{
public class Payment
{
[Key]
public int PaymentID { get; set; }
public decimal Amount { get; set; }
public DateTime DateOfReceipt { get; set; }
public int MemberID { get; set; }
public virtual Member Member { get; set; }
}
}
Code in Relationship.cs
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace Munim_File_Sharing.Models
{
public class Relationship
{
[Key]
public int RelationshipID { get; set; }
public int RequestSenderID { get; set; }
public int RequestReceiverID { get; set; }
public int StatusID { get; set; }
public virtual Member RequestSender { get; set; }
public virtual Member RequestReciever { get; set; }
public virtual StatusMaster Status { get; set; }
}
}
Code in StatusMaster.cs
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace Munim_File_Sharing.Models
{
public class StatusMaster
{
[Key]
public int StatusID { get; set; }
public string Status { get; set; }
public virtual ICollection<Relationship> Relationships { get; set; }
}
}
Connection String in web.Config
<connectionStrings>
<add name="DBCS" connectionString="server=.; database=FileSharingDB; Integrated Security = SSPI" providerName="System.Data.SqlClient" />
</connectionStrings>
Is there any problem in my above classes?
Am I forgetting anything in Models?
Please suggest me as this is my first project in mvc.