Wednesday, 18 September 2013

How to set default register in a database table with EntityFramework Code First?

How to set default register in a database table with EntityFramework Code
First?

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; }
}

No comments:

Post a Comment