I have a Webforms WebApp, and I'm toying with the idea of switching to Entity Framework 6.0 on it.
My idea is to create a dataAccessLayer.dll.
So I decided to spend a day testing the idea, and I'm not sure if I should create a edmx file, or if I'll suppose to hard code using models in a class.
I did import or create a edmx file, but creating the relationships is vague to me, and can't seem to find a decent lesson on it.
I created a couple class files, but the examples I used seem vague as well. This is what the Contoso University Example used in VB.
Example of one of my class files
Imports System.Data.Entity
Imports System.Collections.Generic
Imports System.ComponentModel.DataAnnotations
Imports System.Data.Entity.Infrastructure
Namespace Models
Public Class Customer_Accounts
Public Property ID As Integer
Public Property Advanced As Boolean
Public Property AccountName As String
Public Property FirstName As String
Public Property LastName As String
Public Property EmailAddress As String
Public Property Password As Byte
Public Property PasswordSalt As Byte
Public Property PhraseHint As String
Public Property PhraseAnwser As String
Public Property DateOpened As DateTime
Public Property Lockout As Boolean
Public Property LastLogin As DateTime
Public Property IPAddress As String
End Class
End Namespace
I did a job a couple of months ago in c#, and this guy made his class like this, I can see how this can create the tables in the database.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity;
using System.Linq;
using DataAccessLibrary.Models;
namespace DataAccessLayer.Models
{
publicclass Customer : EntityBase, IValidatableObject
{
#region Public Constructors
public Customer()
{
SalesOrders = new ObservableListSource<SalesOrderHeader>();
Addresses = new ObservableListSource<CustomerAddress>();
}
#endregion Public Constructors
#region Public Properties
[Description("List of addresses for this customer")]
publicvirtual ObservableListSource<CustomerAddress> Addresses { get; set; }
[Description("This customer's business name.")]
[DisplayName("Business Name")]
[StringLength(45)]
[Index(IsUnique = true)]
publicstring BusinessName { get; set; }
I can't see how a table can be created from this class.
Im just looking for some suggestions on how you would do this, or if it even can be done.