is it possible in entity framework to have something like an auto-incremented Id but with own rule?
I want to create a table where the Id looks like:
customer-license + underscore + incrementing number
(Only, if the dataset is created by customer)
the customer-licenses are stored in another entity called License
(each customer gets one license)
LicenseId (str) | Customer (str)
---------------------------------
L0000 | DefaultData
L0001 | Customer 1
L0002 | Customer 2
L0003 | Customer 3
Wanted Resut:
So a dataset would look like:
Id (str) | Name (str)
----------------------------------
1 | Defaultdata-Dataset
L0002_1 | Dataset1 created by Customer 2
L0003_1 | Dataset1 created by Customer 3
L0002_2 | Dataset2 created by Customer 2
So, in time when I worked with Java and Hibernate, I could create a generator that builds my Id.
In entity framework we have something like [DatabaseGenerated()]
that needs a value from DatabaseGeneratedOption
-enum. So it's not possible to use this.
Did someone tried to do something like this. No need for getting the license-ident as prefix (it's just for explaining my target) - how to define an ident-generator would be great.