Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Custom datatypes get lost after adding properties via code #242

Closed
alprinias opened this issue Nov 30, 2020 · 5 comments
Closed

Custom datatypes get lost after adding properties via code #242

alprinias opened this issue Nov 30, 2020 · 5 comments
Labels
bug Confirmed bug released Issue is resolved in a current release
Milestone

Comments

@alprinias
Copy link

During importing a model from a compiled assembly (which was created from scaffolding an existing database) I noticed the following:

All tables of the old database I'm trying to import in the designer had a "Timestamp" column of "timestamp" type in the SQL Server, which was scaffolded as Byte[]. It shows, indeed, as Timestamp:Byte[] in the designer. When I open the "Add properties via code" popup to edit a property, I can see the Timestamp:Byte[] in the list. However, when I finish editing and close the popup, the Timestamp property gets deleted from the designer. It looks like the Byte[] is not recognized and is discarded. I suppose that the empty square brackets are not acceptable in the translation, as the translator expects a number in the brackets for the length.

So, I went on to define the property again in the designer, give it a type of Byte (not Byte array) and a Column Type of "timestamp". However, if I open again the Add Properties via Code and make any change to any property, the custom Column Types are lost after saving. Which I discovered is true also for all the decimal properties, for the Column Types of which I had set e.g. "decimal(10, 4)".

@msawczyn msawczyn added the bug Confirmed bug label Nov 30, 2020
@msawczyn msawczyn added this to the 3.0.1 milestone Nov 30, 2020
@msawczyn
Copy link
Owner

msawczyn commented Dec 1, 2020

I've made a change to translate byte[] to Binary for the model attribute type. Specifying the scale and precision of a decimal isn't supported in the designer yet, but is on the list now that EFCore5 is out.

@msawczyn msawczyn added the pending release Issue is resolved in the current codebase, will be published with the next release label Dec 1, 2020
@alprinias
Copy link
Author

Thanks.
I don't find it necessary to specify scale and precision in the designer. What would be useful is, whatever has been defined as custom column type to be left intact after the "add properties via code" popup is closed. But I presume you delete and re-write all of them at that point... Anyway, it's not crucial.

@msawczyn msawczyn added released Issue is resolved in a current release and removed pending release Issue is resolved in the current codebase, will be published with the next release labels Dec 4, 2020
@msawczyn
Copy link
Owner

msawczyn commented Dec 4, 2020

Released in 3.0.1

@alprinias
Copy link
Author

alprinias commented May 12, 2021 via email

@msawczyn
Copy link
Owner

Hi Alex,

Publishing to the marketplace and publishing to Github are separate things, and are manual processes that don't relate to each other. When 3.5.0.2 was published to the Marketplace, I had neglected to publish a release on Github. Normally, Github will have releases that are more recent then the Marketplace, marked as pre-release, but this was human error.

The designer doesn't look to see what version of the EF assembly is available; it only looks to see which one is specified in the model properties. So if the model specified a distinct version, it should be using that.

To validate that, you can put a breakpoint on any usage of ModelRoot.GetEntityFrameworkPackageVersionNum() where the ModelRoot is available -- easiest place is in the root .tt file for your model -- and see what it returns. That switch statement determines which branch of the code generation template versions will be followed.

Cheers,
-- Michael

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Confirmed bug released Issue is resolved in a current release
Projects
None yet
Development

No branches or pull requests

2 participants