Model with wrong property types
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I am new to Entity Framework. I started with database first approach which created my classes corresponding to the tables I selected. I am using WPF. Unfortunately there is a problem occurred while EF6 was mapping classes. The assigned type for a field is byte while in some cases the value exceeds the byte constraints. So, I want to replace it with either int or double. How do I change the model field types without any changes made for the used database?
namespace DataChrome{
public partial class REGISTRY_MEST{
public byte MEST { get; set; } //Wrong typed field
public string MESTNAME { get; set; }
public Nullable<byte> IDSTRAT { get; set; }
public Nullable<int> MESTOLD { get; set; }
}
}
c# oracle entity-framework
add a comment |
I am new to Entity Framework. I started with database first approach which created my classes corresponding to the tables I selected. I am using WPF. Unfortunately there is a problem occurred while EF6 was mapping classes. The assigned type for a field is byte while in some cases the value exceeds the byte constraints. So, I want to replace it with either int or double. How do I change the model field types without any changes made for the used database?
namespace DataChrome{
public partial class REGISTRY_MEST{
public byte MEST { get; set; } //Wrong typed field
public string MESTNAME { get; set; }
public Nullable<byte> IDSTRAT { get; set; }
public Nullable<int> MESTOLD { get; set; }
}
}
c# oracle entity-framework
1
Since it's database first, can't you just change the database?
– Stefan
Nov 24 '18 at 12:43
Yes! as per suggestion of @Stefan you need to update datatype in DB table & update Model in your project because you are using db first approach. Thanks
– Mayur Lohite
Nov 24 '18 at 13:05
The problem is that I don't have a possibility to change the init db. I'm wandering if there is any alternative option?
– Shamil Khasanov
Nov 24 '18 at 15:33
add a comment |
I am new to Entity Framework. I started with database first approach which created my classes corresponding to the tables I selected. I am using WPF. Unfortunately there is a problem occurred while EF6 was mapping classes. The assigned type for a field is byte while in some cases the value exceeds the byte constraints. So, I want to replace it with either int or double. How do I change the model field types without any changes made for the used database?
namespace DataChrome{
public partial class REGISTRY_MEST{
public byte MEST { get; set; } //Wrong typed field
public string MESTNAME { get; set; }
public Nullable<byte> IDSTRAT { get; set; }
public Nullable<int> MESTOLD { get; set; }
}
}
c# oracle entity-framework
I am new to Entity Framework. I started with database first approach which created my classes corresponding to the tables I selected. I am using WPF. Unfortunately there is a problem occurred while EF6 was mapping classes. The assigned type for a field is byte while in some cases the value exceeds the byte constraints. So, I want to replace it with either int or double. How do I change the model field types without any changes made for the used database?
namespace DataChrome{
public partial class REGISTRY_MEST{
public byte MEST { get; set; } //Wrong typed field
public string MESTNAME { get; set; }
public Nullable<byte> IDSTRAT { get; set; }
public Nullable<int> MESTOLD { get; set; }
}
}
c# oracle entity-framework
c# oracle entity-framework
edited Nov 25 '18 at 10:16
Shamil Khasanov
asked Nov 24 '18 at 12:14
Shamil KhasanovShamil Khasanov
112
112
1
Since it's database first, can't you just change the database?
– Stefan
Nov 24 '18 at 12:43
Yes! as per suggestion of @Stefan you need to update datatype in DB table & update Model in your project because you are using db first approach. Thanks
– Mayur Lohite
Nov 24 '18 at 13:05
The problem is that I don't have a possibility to change the init db. I'm wandering if there is any alternative option?
– Shamil Khasanov
Nov 24 '18 at 15:33
add a comment |
1
Since it's database first, can't you just change the database?
– Stefan
Nov 24 '18 at 12:43
Yes! as per suggestion of @Stefan you need to update datatype in DB table & update Model in your project because you are using db first approach. Thanks
– Mayur Lohite
Nov 24 '18 at 13:05
The problem is that I don't have a possibility to change the init db. I'm wandering if there is any alternative option?
– Shamil Khasanov
Nov 24 '18 at 15:33
1
1
Since it's database first, can't you just change the database?
– Stefan
Nov 24 '18 at 12:43
Since it's database first, can't you just change the database?
– Stefan
Nov 24 '18 at 12:43
Yes! as per suggestion of @Stefan you need to update datatype in DB table & update Model in your project because you are using db first approach. Thanks
– Mayur Lohite
Nov 24 '18 at 13:05
Yes! as per suggestion of @Stefan you need to update datatype in DB table & update Model in your project because you are using db first approach. Thanks
– Mayur Lohite
Nov 24 '18 at 13:05
The problem is that I don't have a possibility to change the init db. I'm wandering if there is any alternative option?
– Shamil Khasanov
Nov 24 '18 at 15:33
The problem is that I don't have a possibility to change the init db. I'm wandering if there is any alternative option?
– Shamil Khasanov
Nov 24 '18 at 15:33
add a comment |
2 Answers
2
active
oldest
votes
So, giving 7 hours to this problem I found the right solution. All you need is just to set user mapping rules in appconfig file. For more details: visit this page.
add a comment |
The type change should be possible by editing the edmx model: click the MEST
property of the class inside the edmx model, then set the Type accordingly in the Properties Window and save the model.
You are running a risk by doing this, as it might be possible to store a value too big for the column if you just change the type this way. You noted that you are using Oracle as the underlying DB, so it might very well be the case that EF generated a "wrong" type for that property.
If you are absolutely sure that the DB will accept the expanded type (int, double) then it should be safe to edit the property as I mentioned at the start. Otherwise you would have to change the DB and generate the class anew - you might need to delete the class from the model and add it again, because not all changes to the table are picked up by the automatic update process.
Can you please point out exactly which class properties should I use? It's not that clear from the comment you've given
– Shamil Khasanov
Nov 24 '18 at 15:39
I edited my answer to be more specific.
– Marty
Nov 24 '18 at 16:18
It doesn't work yet
– Shamil Khasanov
Nov 24 '18 at 17:56
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53458047%2fmodel-with-wrong-property-types%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
So, giving 7 hours to this problem I found the right solution. All you need is just to set user mapping rules in appconfig file. For more details: visit this page.
add a comment |
So, giving 7 hours to this problem I found the right solution. All you need is just to set user mapping rules in appconfig file. For more details: visit this page.
add a comment |
So, giving 7 hours to this problem I found the right solution. All you need is just to set user mapping rules in appconfig file. For more details: visit this page.
So, giving 7 hours to this problem I found the right solution. All you need is just to set user mapping rules in appconfig file. For more details: visit this page.
answered Nov 25 '18 at 10:16
Shamil KhasanovShamil Khasanov
112
112
add a comment |
add a comment |
The type change should be possible by editing the edmx model: click the MEST
property of the class inside the edmx model, then set the Type accordingly in the Properties Window and save the model.
You are running a risk by doing this, as it might be possible to store a value too big for the column if you just change the type this way. You noted that you are using Oracle as the underlying DB, so it might very well be the case that EF generated a "wrong" type for that property.
If you are absolutely sure that the DB will accept the expanded type (int, double) then it should be safe to edit the property as I mentioned at the start. Otherwise you would have to change the DB and generate the class anew - you might need to delete the class from the model and add it again, because not all changes to the table are picked up by the automatic update process.
Can you please point out exactly which class properties should I use? It's not that clear from the comment you've given
– Shamil Khasanov
Nov 24 '18 at 15:39
I edited my answer to be more specific.
– Marty
Nov 24 '18 at 16:18
It doesn't work yet
– Shamil Khasanov
Nov 24 '18 at 17:56
add a comment |
The type change should be possible by editing the edmx model: click the MEST
property of the class inside the edmx model, then set the Type accordingly in the Properties Window and save the model.
You are running a risk by doing this, as it might be possible to store a value too big for the column if you just change the type this way. You noted that you are using Oracle as the underlying DB, so it might very well be the case that EF generated a "wrong" type for that property.
If you are absolutely sure that the DB will accept the expanded type (int, double) then it should be safe to edit the property as I mentioned at the start. Otherwise you would have to change the DB and generate the class anew - you might need to delete the class from the model and add it again, because not all changes to the table are picked up by the automatic update process.
Can you please point out exactly which class properties should I use? It's not that clear from the comment you've given
– Shamil Khasanov
Nov 24 '18 at 15:39
I edited my answer to be more specific.
– Marty
Nov 24 '18 at 16:18
It doesn't work yet
– Shamil Khasanov
Nov 24 '18 at 17:56
add a comment |
The type change should be possible by editing the edmx model: click the MEST
property of the class inside the edmx model, then set the Type accordingly in the Properties Window and save the model.
You are running a risk by doing this, as it might be possible to store a value too big for the column if you just change the type this way. You noted that you are using Oracle as the underlying DB, so it might very well be the case that EF generated a "wrong" type for that property.
If you are absolutely sure that the DB will accept the expanded type (int, double) then it should be safe to edit the property as I mentioned at the start. Otherwise you would have to change the DB and generate the class anew - you might need to delete the class from the model and add it again, because not all changes to the table are picked up by the automatic update process.
The type change should be possible by editing the edmx model: click the MEST
property of the class inside the edmx model, then set the Type accordingly in the Properties Window and save the model.
You are running a risk by doing this, as it might be possible to store a value too big for the column if you just change the type this way. You noted that you are using Oracle as the underlying DB, so it might very well be the case that EF generated a "wrong" type for that property.
If you are absolutely sure that the DB will accept the expanded type (int, double) then it should be safe to edit the property as I mentioned at the start. Otherwise you would have to change the DB and generate the class anew - you might need to delete the class from the model and add it again, because not all changes to the table are picked up by the automatic update process.
edited Nov 24 '18 at 16:18
answered Nov 24 '18 at 13:04
MartyMarty
34927
34927
Can you please point out exactly which class properties should I use? It's not that clear from the comment you've given
– Shamil Khasanov
Nov 24 '18 at 15:39
I edited my answer to be more specific.
– Marty
Nov 24 '18 at 16:18
It doesn't work yet
– Shamil Khasanov
Nov 24 '18 at 17:56
add a comment |
Can you please point out exactly which class properties should I use? It's not that clear from the comment you've given
– Shamil Khasanov
Nov 24 '18 at 15:39
I edited my answer to be more specific.
– Marty
Nov 24 '18 at 16:18
It doesn't work yet
– Shamil Khasanov
Nov 24 '18 at 17:56
Can you please point out exactly which class properties should I use? It's not that clear from the comment you've given
– Shamil Khasanov
Nov 24 '18 at 15:39
Can you please point out exactly which class properties should I use? It's not that clear from the comment you've given
– Shamil Khasanov
Nov 24 '18 at 15:39
I edited my answer to be more specific.
– Marty
Nov 24 '18 at 16:18
I edited my answer to be more specific.
– Marty
Nov 24 '18 at 16:18
It doesn't work yet
– Shamil Khasanov
Nov 24 '18 at 17:56
It doesn't work yet
– Shamil Khasanov
Nov 24 '18 at 17:56
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53458047%2fmodel-with-wrong-property-types%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Since it's database first, can't you just change the database?
– Stefan
Nov 24 '18 at 12:43
Yes! as per suggestion of @Stefan you need to update datatype in DB table & update Model in your project because you are using db first approach. Thanks
– Mayur Lohite
Nov 24 '18 at 13:05
The problem is that I don't have a possibility to change the init db. I'm wandering if there is any alternative option?
– Shamil Khasanov
Nov 24 '18 at 15:33