Entity Framework Implicit Type Conversion
<p>Lets say I have an account number in the format of <code>YYYY-NNNNNC</code>, where <code>Y</code> is a Year digit, <code>N</code> is a number, and <code>C</code> is a Luhn checksum digit.</p>

<p>Example: <code>2016-426013</code></p>

<p>It can exist as a string with all the information that it would have if it were in class form:</p>

<pre><code>public class AccountNumber
{
    public int Year { get; set; }
    public int Number { get; set; }
    public int Checksum { get; set; }
}
</code></pre>

<p>Now, in my application I would much rather be dealing with this nice object than a string that I may need to parse. But in the database it is almost necessary for it to exist as a string.</p>

<p>I've written my implicit conversions</p>

<pre><code>public static implicit operator string(AccountNumber an)
</code></pre>

<p>And</p>

<pre><code>public static implicit operator AccountNumber(string s)
</code></pre>

<p>Is there any way that I can make EF store a class like this:</p>

<pre><code>public class Account
{
    public AccountNumber AccountNumber { get; set; }
    ...
}
</code></pre>

<p>But have it convert the <code>AccountNumber</code> to and from a <code>string</code> for the purposes of database storage?</p>