本文接续自《Code-First 在SQLServer Compact 4.0 中的应用(一),基础配置》,解决数据库架构需要变更时遇到的问题。
回顾例子中的代码(改用MVC描述):
public
class
LiangyichenDBContext : DbContext
{
public
DbSet<LiangyichenDB> Items {
get
;
set
; }
}
public
class
LiangyichenDB
{
[Key]
public
int
index {
get
;
set
; }
public
string
title {
get
;
set
; }
public
DateTime pubdate {
get
;
set
; }
}
|
public
ActionResult Index()
{
var context =
new
LiangyichenDBContext();
context.Items.Add(
new
|