ef code first - EF CodeFirst ,how to add custom model to create table? -
i work on asp.net mvc 5.1 , follow this post create own userprofile table table per type (tpt) method.
but how want add model code first?
for example, want add independent table country table , currency table, create following classes:
country.cs
namespace miapos.models { public class country { // primary key public int countryid { get; set; } [required] public string name { get; set; } } }
currency.css
namespace miapos.models { public class currency { // primary key public int currencyid { get; set; } [required] public string name { get; set; } } }
datacontext.cs
using system; using system.collections.generic; using system.data.entity; namespace miapos.models { public class datacontext : dbcontext { public dbset<country> countries { get; set; } public dbset<currency> currencies { get; set; } } }
i place above of them on models folder, how can recognize codefirst add-migration command on nuget console? saw post ef auto generate migration class if inherit system.data.entity.dbcontext class.
Comments
Post a Comment