如何将EF Code First Apps部署到生产环境

时间:2013-11-22 10:40:09

标签: entity-framework asp.net-mvc-4 ef-code-first

我写了mvc4 web api应用程序。我有模型和控制器。控制器包含很多Get和Post方法。在本地机器上,avrything工作正常。但现在我试图将我的应用程序共享到生产服务器。 这是我的型号代码:

using System;
using System.Collections.Generic;
using System.Data.Entity;

namespace Alllarm.DataContext.Models
{
public class UpdateStatus
{
    public bool Success { get; set; }
    public long ID { get; set; }
}

public class Device
{
    public long Id { get; set; }
    public string DeviceID { get; set; }
    public string Platform { get; set; }
    public virtual List<User> Users { get; set; }
}

public class User
{
    public long Id { get; set; }
    public string FacebookID { get; set; }
    public string AccessToken { get; set; }
    public DateTime UpdateTime { get; set; }
    public bool? FbStatus { get; set; }
    public bool? SmsStatus { get; set; }

    public virtual Device Device { get; set; }
    public virtual List<Alarm> Alarms { get; set; }
}

public class Alarm
{
    public long Id { get; set; }
    public DateTime StartDate { get; set; }
    public int Snoozes { get; set; }
    public bool Repeat { get; set; }
    public DateTime AlarmUpdateTime { get; set; }

    public virtual User User { get; set; }
    public virtual List<FacebookNotificationStatus> StatusUpdates { get; set; }
    public virtual Sms Sms { get; set; }
}

public class FacebookStatusUpdate
{
    public long Id { get; set; }
    public DateTime FacebookUpdateTime { get; set; }
    public string PostId { get; set; }
    public DateTime? FacebookPostTime { get; set; }
    public DateTimeOffset ClientTime { get; set; }
    public int Offset { get; set; }

    public virtual FacebookNotificationStatus Status { get; set; }
    public virtual Alarm Alarm { get; set; }
}

public class Sms
{
    public long Id { get; set; }
    public string Message { get; set; }

    public virtual List<PhoneNumber> SmsNumbers { get; set; }
}

public class PhoneNumber
{
    public long Id { get; set; }
    public string Number { get; set; }
}

public enum FacebookNotificationStatus
{
    MessagePosted,
    Cancelled,
    Active,
    Deactivated,
    Overslept
}

public class FBAppContext : DbContext
{
    public DbSet<Device> Devices { get; set; }
    public DbSet<User> Users { get; set; }
    public DbSet<Alarm> Alarms { get; set; }
    public DbSet<FacebookStatusUpdate> FacebookStatusUpdates { get; set; }
    public DbSet<Sms> Smses { get; set; }
    public DbSet<PhoneNumber> PhoneNumbers { get; set; }
}

}

请告诉我如何在生产服务器上运行我的应用程序。

1 个答案:

答案 0 :(得分:1)