Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

How to store things like ethnicity, religion etc. and make it multilingual (EF Core, code first)

$
0
0

I'm creating application with Entity Framework Core and ASP.NET Core. I need to store things like ethnicity, religion and have pre-defined set of values for it. I'm not sure what would be the best way to do it.

For example, religion I would like to have predefined set of values:

  • Buddhism
  • Hinduism
  • Islam
  • Christianity
  • etc...

And have it in multiple languages, each person can have multiple ethnicities (I don't know about religions, but let's suppose too).

Should I represent religion and ethnicity as enum in my code(and put it in 1 table), or should I create those things in form of classes like:

public class Religion
{
	public int ReligionId { get; set; }
	public string Name { get; set; }
}

public class Ethnicity
{
... same as above
} public class Person { public int PersonId { get; set; } public virtual List<Religion> Religions { get; set; }
public virtual List<Ethnicity> Ethnicities { get; set; } }

(The above example probably is not even possible atm, https://github.com/aspnet/EntityFrameworkCore/issues/1368)

So that would have more normalized form after database migration.

Any recommendation on how to do it?


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>