logo
down
shadow

DbMigration.AlterstoredProcedure (Entity Framework migration): How to represent type smallmoney?


DbMigration.AlterstoredProcedure (Entity Framework migration): How to represent type smallmoney?

By : user2950552
Date : November 17 2020, 11:55 AM
I hope this helps . , nemesv, for the hint in your comment! What I was missing is that the types being specified while setting up the stored procedure parameters, i.e. "Int" and "String" in:
code :
c => new
    {
        ItemID = c.Int(),
        ItemName = c.String(),
        //...
    }
    ItemCost = c.Decimal(precision: 10, scale: 4, storeType: "smallmoney")
public override void Up()
{
    this.AlterStoredProcedure("dbo.EditItem", c => new
    {
        ItemID = c.Int(),
        ItemName = c.String(),
        ItemCost = c.Decimal(precision: 10, scale: 4, storeType: "smallmoney")
    },
    @" (New sproc body SQL goes here) ");
}
ALTER PROCEDURE [dbo].[EditItem]
    @ItemID [int],
    @ItemName [nvarchar](max),
    @ItemCost [smallmoney]
AS
BEGIN
    (New sproc body SQL goes here)
END


Share : facebook icon twitter icon
How to alter column to identity using entity framework dbmigration?

How to alter column to identity using entity framework dbmigration?


By : Vasu1819
Date : March 29 2020, 07:55 AM
I hope this helps . Since you reverse-engineered the database when the Id column was not set as IDENTITY yet, the code first model has been generated with DatabaseGeneratedOption.None set for the Id property on the entity.
That causes EF to create an insert statement with the Id set, which no longer works after changing the column to IDENTITY.
DbMigration & DbModelBuilder behavior before compilation in Entity Framework

DbMigration & DbModelBuilder behavior before compilation in Entity Framework


By : user2358111
Date : March 29 2020, 07:55 AM
To fix the issue you can do I just checked the database after its creation, and found that in fact NVARCHAR is the data type of all string properties I declared in the class model without needing to specify IsUnicode over them.
This looks to be the default for SQL Server provider at least.
Calling Entity Framework models from inside DBMigration Up()

Calling Entity Framework models from inside DBMigration Up()


By : James Beggs
Date : March 29 2020, 07:55 AM
I wish this helpful for you When a migration is scaffolded for you, it has no calls against your model and that is intentionally so. If you used your own models in an Up() in an early migration and then decided you didn't need those models anymore that migration would be pooched.
You are correct in thinking that the Seed method is built specifically to handle adding relevant data like universal lookups, etc. If you were to remove a lookup table all together, you'd simply just remove that seeding logic that no longer is required.
Entity Framework context.database.create() still goes through my Class : DbMigration

Entity Framework context.database.create() still goes through my Class : DbMigration


By : Healer
Date : March 29 2020, 07:55 AM
it fixes the issue Im not sure why you are implementing the "exact"/close to functionality of how EF migrations works yourself?
Isn't what your after a CreateDatabaseIfNotExists Db initialization strategy? Or is it just me not reading your question good enough?
code :
public class SchoolDBContext: DbContext 
{   
    public SchoolDBContext(): base("SchoolDBConnectionString") 
    {
        Database.SetInitializer<SchoolDBContext>(new CreateDatabaseIfNotExists<SchoolDBContext>());

        //Database.SetInitializer<SchoolDBContext>(new DropCreateDatabaseIfModelChanges<SchoolDBContext>());
        //Database.SetInitializer<SchoolDBContext>(new DropCreateDatabaseAlways<SchoolDBContext>());
        //Database.SetInitializer<SchoolDBContext>(new SchoolDBInitializer());
    }
    public DbSet<Student> Students { get; set; }
    public DbSet<Standard> Standards { get; set; }
}
Entity Framework/dbMigration - Unwanted decimal rounding

Entity Framework/dbMigration - Unwanted decimal rounding


By : doctorbigtime
Date : March 29 2020, 07:55 AM
I wish this help you I think your migration is not executing and database is created with decimal(18, 2) by default.
You can try to use the following initializer, but it does not created database for your
code :
Database.SetInitializer<ConfiguratorContext>(new MigrateDatabaseToLatestVersion<ConfiguratorContext, Configuration>());
Related Posts Related Posts :
  • C# correct exception handling
  • "Could not open macro storage" when accessing using file on another machine
  • How to access other directories of hosted server
  • C# Jagged Array check if value exists/true
  • Why can't I type Clone() properly?
  • exception on accessing dictionary from list
  • Getting the immediate response from server without waiting to 200 message
  • Why am I getting exception Directory Is Not empty?
  • Could not load file or assembly 'CefSharp.dll' or one of its dependencies
  • Sending Email By Using C# in unity3D?
  • Correct usage of await async in webapi
  • Program update code issue
  • Marshal.Copy attempted to read or write protected memory At Random Times
  • Restrict Type variable to specific class or subclass
  • Horizontal text alignment in a PdfPCell
  • C# crashing with Form.show() command, ObjectDisposedException - Deeper look / explanation please
  • Will the result of a LINQ query always be guaranteed to be in the correct order?
  • "Could not find default endpoint element that references contract"
  • Umbraco Request.QueryString is null if it's the first time the page is loaded
  • Error inconsistent accessibility method C#
  • How to program Intel Xeon Phi with C#?
  • remove nested element using regular expression
  • Is there a C# alternative to Java's vararg parameters?
  • Clear particular column values in DataTable
  • how to add event handler to programatically created checkboxes
  • Cannot apply indexing with [] to an expression of type 'System.Collections.Specialized.NameValueCollection'
  • Check for key in pre-existing dictionary in case insensitive manner
  • How to remove year from datetime object?
  • Accessing Settings in different ways
  • "This project is empty" error in Sonarqube
  • How to create reusable icon menu in Xamarin
  • Value Cannot be null in Ado.Net connectivity
  • Adding a custom/dynamic attribute when using XSD.exe
  • How to convert object to correct type
  • Automatically sign out from Forms Authentication in ASP.NET when browser is closed
  • Can a WCF service support both Buffered and Streamed transfer modes?
  • Verify a CA Certificate with a public key in C#
  • How to invoke a Web Service that requires the "patch" verb using the C# WebClient wrapper?
  • Proper way a implementing property based on generic type
  • Closing a form that is created in another thread
  • How Can You Bind a List<String> to a StackPanel
  • WPF Application Update Best Practices - Architectural Explanation
  • System.UnauthorizedAccessException in Server.MapPath()
  • Connecting and Using SQL Compact Edition in a WPF application
  • C#: weird ref in constructor to behave like "virtual field"
  • C# XDocument Load with multiple roots
  • How to decide what goes in the Domain or Application Project in a "DDD" solution?
  • How to get/set a property of an interface that is not always implemented
  • Read-only array field in unsafe struct
  • i got "Invalid attempt to call Read when reader is closed" when using sqldatareader how to solve it in a three
  • Why should I encapsulate objects in using if there is garbage collection
  • How to load Word document from byte array
  • Caliburn.Micro and ContextMenu for DataGrid Row
  • Linq "join" with a IList<T> getting "Error Unable to create a constant value.."
  • How to draw red wavy line under words in RichTextBox c# winform
  • HttpPostedFileBase returns Null MVC3
  • Refresh Dropdownlist in webform
  • How to convert serialized byte array back to its text form
  • How to do a loop to check all the variables at the same time for C#?
  • Facebook Sentiment Analysis API
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org