0

I'm trying create a system using EntityFramework code first for connect my database, I'm using code first, because I want it create database and tables automatic if not exist.

So, I want when my Logins table is created, it insert a first register, user Admin and password Admin

How to I do this?

My code:

public class Login
{
    public int Id { get; set; }
    public string UserName { get; set; }
    public string Password { get; set; }
}

public class MySystemContext : DbContext
{
    DbSet<Login> Logins { get; set; }
}
4

1 回答 1

1

这称为为数据库播种,请在此处查看简要教程。Julie Lerman 在这里也有一篇关于它的博客文章。

于 2013-09-18T13:25:15.383 回答