title: Data Annotation or Fluent API? Best Practise for supporting various ORM's
body: <p>I am looking into implementing a form a Data Validation on at the Data Layer of my application. I am looking to accept a specific string input into my data model, but am struggling to know how best to implement this.</p>
  
  <p>I am currently looking into whether Fluent API (currently testing EF Core flavor) will facilitate this functionality, or whether I need to consider bringing in Data Annotations into my Data Layer model to ensure the validation can be implemented on all Object Relational Modeling services.</p>
  
  <p>From reading around online, Fluent API is the best course of action as it removes workload from the Data Layer and lets the Data Access layer control and specify the specific rules around how the data will be modeled.</p>
  
  <p>The downside is that I would need to re-implement this for other ORM's (i.e.: NPoco) to meet the rules of this platform.</p>
  
  <p><strong>A bit more on the problem</strong></p>
  
  <p>I have several classes that will have foreign cultured names and strings, and they can be identified by a Language Culture String, using the ISO-639 and ISO-3166 combination. (en-GB, zh-CN)</p>
  
  <p>This is represented by a String in the Data Model.</p>
  
  <pre><code>public abstract class Alias
  {
      public string Culture { get; set; }
  }
  </code></pre>
  
  <p>Under EF Core, I set up the tables using the OnModelCreating function.</p>
  
  <pre><code>protected override void OnModelCreating(ModelBuilder modelBuilder)
  {
      var authorAlias = modelBuilder.Entity&lt;AuthorAlias&gt;();
      authorAlias.Property("Given").IsRequired().IsUnicode();
      authorAlias.Property("Family").IsRequired().IsUnicode();
      authorAlias.Property("Middle").IsUnicode();
  
      base.OnModelCreating(modelBuilder);
  }
  </code></pre>
  
  <p>I know .NET Core has the ability to pull down an array of CultureInfo which use the Localization String system I want to implement, but I do not intend the Data Model to check this but to let the Data Access layer validate the data.</p>
  
  <p>How can I ensure that my intended logic can be implemented into the system? And would I need to change to Data Annotations to ensure this logic?</p>