Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SqlServer: Scaffold Identity on a non-key appropriately #8688

Closed
smitpatel opened this issue Jun 2, 2017 · 6 comments
Closed

SqlServer: Scaffold Identity on a non-key appropriately #8688

smitpatel opened this issue Jun 2, 2017 · 6 comments
Labels
closed-out-of-scope This is not something that will be fixed/implemented and the issue is closed.

Comments

@smitpatel
Copy link
Contributor

smitpatel commented Jun 2, 2017

After #8680 , scaffolding code will do nothing about identity column,

  1. It should put annotation appropriately on DatabaseModel.
  2. It should print out appropriate fluent API for column which gets identity by convention but is not actually identity.
  3. It should print out fluent API for column which will not get identity by convention but is identity column.
    4. Log warning for identity appearing on invalid property type. (if any)
@ajcvickers
Copy link
Contributor

Also do this for SQLite auto-increment.

@ajcvickers ajcvickers added this to the 2.0.0 milestone Jun 2, 2017
@bricelam
Copy link
Contributor

bricelam commented Jun 8, 2017

See also #8140

@bricelam bricelam self-assigned this Jun 8, 2017
@bricelam bricelam removed their assignment Jun 28, 2017
@ajcvickers ajcvickers modified the milestones: 2.0.0, Backlog Jun 29, 2017
@divega divega removed this from the Backlog milestone Jun 30, 2017
@divega
Copy link
Contributor

divega commented Jun 30, 2017

Clearing up milestone. I would like to understand the impact of this better before we punt.

@smitpatel
Copy link
Contributor Author

From what I understand of current codebase,
When scaffolding db, if the column is identity, we scaffold ValueGenerated.OnAdd. Which SqlServer by convention setups with identity. If column is not identity then ValueGenerated.OnAdd is not put and using key convention, we make ValueGeneratedNever() (unless some other code like Sequence marks it otherwise. So identity should just work fine (as @bricelam found during verification of preview2 packages).

@bricelam can provide more info on his testing.

@bricelam
Copy link
Contributor

Yes, the reverse engineered model is fully compatible with the database. The minor improvement would be to generate .UseSqlServerIdentityColumn() in the C# for non-key columns. This would make the model round-trip-able with Migrations.

@ajcvickers ajcvickers added this to the Backlog milestone Jun 30, 2017
@bricelam bricelam self-assigned this Sep 5, 2017
@ajcvickers ajcvickers changed the title SqlServer: Scaffold Identity appropriately SqlServer: Scaffold Identity on a non-key appropriately Sep 7, 2017
@ajcvickers ajcvickers modified the milestones: 2.1.0, Backlog Sep 7, 2017
@ajcvickers ajcvickers removed this from the 2.1.0-preview1 milestone Jan 17, 2018
@ajcvickers ajcvickers added this to the 2.1.0 milestone Jan 17, 2018
@divega divega modified the milestones: 2.1.0-preview2, 2.1.0 Apr 2, 2018
@bricelam
Copy link
Contributor

This is working as expected. It generates .ValueGeneratedOnAdd() which, by convention, leverages the IDENTITY column.

@bricelam bricelam removed their assignment Apr 12, 2018
@bricelam bricelam removed this from the 2.1.0 milestone Apr 12, 2018
@ajcvickers ajcvickers added the closed-out-of-scope This is not something that will be fixed/implemented and the issue is closed. label Mar 10, 2022
@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-out-of-scope This is not something that will be fixed/implemented and the issue is closed.
Projects
None yet
Development

No branches or pull requests

4 participants